jQuery- Toggle Up and Dowm

HTML:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<div id="faq-list">
 <div class="overflow">
    <div class="to-bottom-border">
    <h2 class="ques">Click 1</h2>
    <div style="display:none;" class="answer">
     <p>Expanded 1</p>
     </div>       
     </div>
 
<div class="to-bottom-border">
    <h2 class="ques">Click 2</h2>
    <div style="display:none;" class="answer">
     <p>Expanded 1 </p>
     </div>       
     </div>     
</div>
</div>
SCRIPT:
1
2
3
4
5
6
7
jQuery(document).ready(function() {
    jQuery('#faq-list h2').click(function() {
       jQuery(this).next('.answer').slideToggle(500);
       jQuery(this).toggleClass('close');
        
    });
}); // end ready
Important: Please make sure, jQuery library is included in the page.

No comments:

Post a Comment