Posted By

diogoweb on 05/03/11


Tagged


Versions (?)

Show/hide more content on click


 / Published in: jQuery
 

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

  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. });

Report this snippet  

You need to login to post a comment.