Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67497

how to append a div content to a class only once?

$
0
0

I have several images as slide. On clicking next button, images are being slide shown but i want to add a text for each image over the image. javacsript code:

afterShow: function( instance, current ) {


    //alert($(this).find('img').attr('alt'));

    var url = window.location.href;
    var cat = url.substring(url.lastIndexOf('#') + 1); 
    var cats = cat.split('-');
    catId= cats[0];
    var index=catId+$("[data-fancybox-index]").html();
    //alert($("[data-fancybox-index]").html());
    //$('.fancybox-slide').children(".imagecontainer").remove();

    //alert($("#d_" + index).length);
    if($("#d_" + index).length == 0) {
        var strDiv='<div id="d_'+index+'" class="centerdivCont"></div>';
        $(".fancybox-content").append(strDiv);
        return false;

    }

    /*if($("#d_" + index).length> 0) {
        var strDiv='<div id="d_'+index+'" class="centerdivCont"></div>';
        $(".fancybox-content").remove(strDiv);
    }else{
        var strDiv='<div id="d_'+index+'" class="centerdivCont"></div>';
        $(".fancybox-content").append(strDiv);
    }*/

        //alert($("#d_" + index).length);


    //$(".fancybox-slide").append($('#'+index).html());

},

Viewing all articles
Browse latest Browse all 67497

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>