Arkadiusz Raszeja Arkadiusz Raszeja - 1 year ago 105
HTML Question

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

I have a list generated by foreach:

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

Then I use jQuery to make hiddenValues visible:

$(".MagicButton").click(function () {

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:


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

Answer Source
$(".MagicButton").click(function () {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download