Show parent element element
Let's 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 press more link
it toggles
hidden class
. but not both hidden classes.
I tried to edit some things with help $(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;
}
);
Now it works. :( I hope you understand my question ... Thanks!
+1
twodayslate
source
to share
2 answers
This may not be the most efficient solution, but try this:
$(".row #more").click(function() {
$(this).parents(".row").children(".hidden").slideToggle("slow");
}
);
This should work if I understood your question correctly.
+1
Darko z
source
to share
$('a[href=#more]').click(function() {
$(this).parents('.row > div.hidden').slideToggle('slow');
});
+1
tvanfosson
source
to share