views:

67

answers:

2

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!

+1  A: 

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.

Darko Z
That worked. Thanks! And I get what you did! Double bonus!
twodayslate
@tvanfosson it does not appear so.
twodayslate
Did you use .more or #more, #more selects by name. Actually, now that I think about it, I'm not sure how it would work with #more since there are no elements named #more.
tvanfosson
I assumed he thought I meant id="more"
twodayslate
yes i mean you a need an id="more", but as you know it can be anything just make sure your selector and your link id (or class) match! :)
Darko Z
+1  A: 
$('a[href=#more]').click(function() {
    $(this).parents('.row > div.hidden').slideToggle('slow');
});
tvanfosson