Note that there are some explanatory texts on larger screens.

plurals
  1. POworking with a item in a table with jquery
    primarykey
    data
    text
    <p>I have a table with items in a row, each item have a button.</p> <p>I want to click on that button and get the values from my item. Like "You have clicked button1 and the name of you item is item1"</p> <p>Oh, ofcourse I do this in a repeater and the I have the primarykey as the tr id. </p> <p>I have a <a href="http://jsfiddle.net/mU3yz/15/" rel="nofollow">jsfiddle</a> example that my explain more, right now the only working thing is that when I click on the button it shows the buttonname.</p> <p>Thanks in advance!</p> <p>Html</p> <pre><code>&lt;table id="presTable"&gt; &lt;tr&gt; &lt;th&gt;&lt;/th&gt; &lt;th&gt; Name &lt;/th&gt; &lt;th&gt; Adress &lt;/th&gt; &lt;/tr&gt; &lt;tr id="Name0" class="itemRow"&gt; &lt;td&gt; &lt;input type="button" class="ss" id="Button0" value="Test"/&gt; &lt;/td&gt; &lt;td&gt; &lt;span id="nameSpan"&gt;Name0&lt;/span&gt; &lt;/td&gt; &lt;td&gt; &lt;span id="spanAdress"&gt; Adress0&lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr id="Name1" class="itemRow"&gt; &lt;td&gt; &lt;input type="button" class="ss" id="Button1" value="Test"/&gt; &lt;/td&gt; &lt;td&gt; &lt;span id="nameSpan"&gt;Name1&lt;/span&gt; &lt;/td&gt; &lt;td&gt; &lt;span id="spanAdress"&gt; Adress1&lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr id="Name2" class="itemRow"&gt; &lt;td&gt; &lt;input type="button" class="ss" id="Button2" value="Test"/&gt; &lt;/td&gt; &lt;td&gt; &lt;span id="nameSpan"&gt;Name2&lt;/span&gt; &lt;/td&gt; &lt;td&gt; &lt;span id="spanAdress"&gt; Adress2&lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>Jquery</p> <pre><code>$(function () { $('tr.itemRow &gt; td &gt; input.ss').each(function (row) { $(this).click(function (button) { alert("You have pushed the button " + $(this).attr("id")); }); }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload