Sunday, 12 October 2014

Jquery multiple slide toggle

HTML

<a href="#" class="comments">Show Comments</a><br />
<div class="toggleComments" style="display:none;">This is #comment1 <br />This is #comment2 <br /></div>

JavaScript

var toggle = false;
$(function() {
 
    $(document).on('click', 'a.comments', function(e) {
        $('.toggleComments').hide();
        var $this = $(this);
         $('.comments').text('Show Comments');
            $this.text('Hide Comments');
        $(this).nextAll('.toggleComments:first').toggle(1000,function() {  
        });
        e.preventDefault();
    });
});

No comments:

Post a Comment