Jump to content

codebyren

Members
  • Posts

    156
  • Joined

  • Last visited

Everything posted by codebyren

  1. If the divs are siblings in the HTML then you can use the next() or nextall() method - something like this: $('.tricks_head').click(function() { var $tricks_head = $(this); $tricks_head.next('.trick').toggle('slow'); }); Updated demo here: http://jsfiddle.net/codebyren/AqSp2/1/
  2. Do you have control of the HTML mark-up? If so, you could try something like this: <div class="tricks_head"> <div class="trick"> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptates, totam. </div> </div> <div class="tricks_head"> <div class="trick"> Ratione, maiores labore nulla atque recusandae repellendus est. Iusto, ut. </div> </div> With non-numeric classes for the divs, the JavaScript is fairly simple: $('.tricks_head').click(function() { var $tricks_head = $(this); $tricks_head.find('.trick').toggle('slow'); }); You can see a working demo here: http://jsfiddle.net/codebyren/AqSp2/
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.