Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery: didnt get button id on click
    primarykey
    data
    text
    <p>I am facing a problem in the jquery click event. actually i was append some <strong>tr</strong> in table. my code is given below.</p> <p><em><strong>HTML CODE:</em></strong></p> <pre><code> &lt;table id="tblList"&gt; &lt;thead&gt; &lt;tr&gt;&lt;th&gt;Country Name&lt;/th&gt; &lt;th&gt;CityName&lt;/th&gt;&lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt;&lt;/tbody&gt; &lt;/table&gt; </code></pre> <p><em><strong>JQUERY CODE:</em></strong></p> <p><code>var rowsCount = $("#tblList tbody").find("tr").length; var table = "&lt;tr&gt;&lt;td&gt;" + countryName + "&lt;/td&gt;&lt;td&gt;" + cityName + "&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td colspan='2'&gt;&lt;div id='divGridRow'&gt;&lt;input type='button' value='add Zip Code' id='btn" + rowsCount + "' class='gridButton'/&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;"; $('#tblList').append(table);</code></p> <p>above code is working fine. now i want to show dialog when click on my <strong>addZipCode</strong> button.</p> <p>i was write below code for get the button id.</p> <pre><code> $("#tblList tbody").bind('click', function() { $(this).find("tr").bind('click', function() { $(this).find("input").bind('click', function() { console.log($(this).attr("id")); }); }); }); </code></pre> <p>but still not successful to get button id 100%. In the above code i have face one more issue. if i click first time on button, no value display in <strong>console.log</strong>, when click third time,then only one time BUTTON ID is display <strong>btn0</strong> and when i click fourth time then button id is display three time <strong>btn0 btn0 btn0</strong> and when i click fifth time then button id is display 6 time atones like this <strong>btn0 btn0 btn0 btn0 btn0 btn0</strong></p> <p>i append multiple rows in table, and every button in row have a unique id like btn0, btn1,btn2..... simple i want to try to get button id on click.</p> <p>please help me to find the solution. Thanks in advance.</p> <p>please check your self in jsfilddle <a href="http://jsfiddle.net/umairnoor84/y25LW/" rel="nofollow">http://jsfiddle.net/umairnoor84/y25LW/</a></p>
    singulars
    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