Skip to content Skip to sidebar Skip to footer

Jquery Only Toggle One Element Without Having To Use Ids

i have multiple divs with the same class on my page. I want to be able to toggle them individually. Using this script: $(document).ready(function() { $('.file').hide(); $('

Solution 1:

Maybe you could try with this:

$(this).parent('h5').next('div.file').slideToggle(1000);

Edit: Here's an example: http://jsfiddle.net/6GRJr/


Solution 2:

this is because it's always hiding all your divs with class file do it like this

$(document).ready(function() {
   $('.file').hide();

   $('a.toggle').click(function() {
      $('div.file', this.parentNode).slideToggle(1000);
      $(this).text($(this).text() == 'show' ? 'hide' : 'show');
      return false;
   });
 });

Post a Comment for "Jquery Only Toggle One Element Without Having To Use Ids"