Show/hide more content on click


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <p><a href="#how-to" class="toggle">How to write a good article?</a></p>
  2. <div id="how-to">
  3. How to tips go here.
  4. </div>
  5. $('a.toggle').toggle(function() {
  6. var id = $(this).attr("href");
  7. $(this).addClass("active");
  8. $(id).slideDown();
  9. }, function() {
  10. var id = $(this).attr("href");
  11. $(this).removeClass("active");
  12. $(id).slideUp();
  13. });

URL: http://eisabainyo.net/weblog/2010/09/01/10-useful-jquery-snippets/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.