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

How Set Open and Close of specific div block only using Javascript?

$
0
0

Please check this Link https://jsfiddle.net/bhargavjoshi/sL8f6bkr/3/

I am trying to setup Open a block by clicking continue reading and closing the block by clicking show less.

now it's normally working fine but the issue is when I am opening two blocks for eg. 1 and 2 point are open and If am clicking show less of point no 1 then it will close first block but also change the status of show less to continue reading of block 2.

so how can I set that by clicking show less it will close only specific that block only.

jQuery(".show-slide-wrp").on("click", function(event){
    event.preventDefault();
    var slidindWrp = jQuery(this).data("slide");
    console.log(slidindWrp);
    jQuery(slidindWrp).slideDown();
    jQuery(this).hide();
});


jQuery(".hide-slide-wrp").on("click", function(event){
    event.preventDefault();
    var $this = jQuery(this);
    var closeDiv = $this.closest(".sliding-wrp");
    jQuery(".show-slide-wrp").show();
    closeDiv.slideUp();
    jQuery('html, body').animate({
        scrollTop: closeDiv.offset().top - 300
    }, 500);

});

// scoll by id
jQuery(".contenttable a").click(function(event) {
    event.preventDefault();
    var $this = jQuery(this);
    var getScrollId = $this.attr("href");  
    console.log(getScrollId);
   jQuery('html, body').animate({
        scrollTop: jQuery(getScrollId).offset().top
    }, 500);
});

Viewing all articles
Browse latest Browse all 67469

Trending Articles



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