Arkadiusz Raszeja Arkadiusz Raszeja - 1 month ago 5
HTML Question

jQuery, :first on the list, but not first at all

I have a list generated by foreach:

<div class="rowClass">
<div>
<input class="MagicButton" value="click to show hidden values in row"/>
</div>
<div class="hiddenValues"></div>
</div>


Then I use jQuery to make hiddenValues visible:

$(".MagicButton").click(function () {
$(".hiddenValues:first").slideDown("slow");
});


The problem is, when I use this on any row it happens only in first one. Without ":first" it works on all the rows. What can I do to make it happen only on the row I'm working on?

Edit: Button to be clicked is in another div, so it is still not working.
Edit2: The solution is:

$(this).parent().parent().find(".HiddenValues").slideDown("slow");


Each parent() jumps higher in div's tree to finally search for .hiddenValues inside rowClass.
Thanks for everything! You made me solve it.

Answer
$(".MagicButton").click(function () {
    $(this).parent().find(".hiddenValues").slideDown("slow");
});