Question

Lets say we have something like:

 <div class="row">
      <div class="box">
          <a class="more" href="#more"/>
      </div>
      <div class="hidden">
          stuff
      </div> 
 </div>
 <div class="row">
      <div class="box">
          <a class="more" href="#more"/>
      </div>
      <div class="hidden">
          stuff
      </div>  
  </div>

So when you click on the more link it toggles the hidden class. but not both hidden classes.

I tried to edit some stuff with $(this) but nothing.

Just started jquery/js so not the best with it.

This is what I have

$(".row .more").click( 
        function()
        {
            var parentTag = $(this);
            var parentTag = "." + $(this).parent().parent().parent().attr('class') + "";
            //$(this).prepend(document.createTextNode(parentTag));      
            $(parentTag + " .forum-stats").slideToggle("slow");
            return false;
        }
    );

It does now work. :( I hope you understand my question... Thanks!

Was it helpful?

Solution

This may not be the most efficient solution but try this:

$(".row #more").click(function() {
        $(this).parents(".row").children(".hidden").slideToggle("slow");    
    }
);

That should work, if I understood your question correctly.

OTHER TIPS

$('a[href=#more]').click(function() {
    $(this).parents('.row > div.hidden').slideToggle('slow');
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top