Posted By

Alwaison on 07/11/11


Tagged

toggle event jquery clic


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

spee66


Toggle element in jQuery


 / Published in: jQuery
 

URL: http://jsfiddle.net/Alwaison/7d8Bu/

  1. function initShowHideContent(){
  2. if($('a.show-hide').length){
  3. $('a.show-hide').each(function(){
  4. if($(this).hasClass('hide')){
  5. $(this).next().hide();
  6. }
  7. });
  8. $('a.show-hide').click(function(){
  9. $(this).next().toggle();
  10. if($(this).hasClass('hide')){
  11. $(this).removeClass('hide').addClass('active');
  12. }else{
  13. $(this).removeClass('active').addClass('hide');
  14. }
  15. return false;
  16. });
  17. }
  18. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: Alwaison on July 11, 2011

Works fine in jQuery 1.2.6 or higher

Posted By: BebenKoben on July 12, 2011

hihihihi...look at here, i'm make similar too ;) http://jsfiddle.net/bebenkoben/cTxf4/show/

You need to login to post a comment.