javascript - Get id of clicked element using jquery -


this question has answer here:

i have series of select boxes within table. html is:

<td id="1">   <select id="a" name="xxx">       <option ... </option>   </select> </td>  <td id="2">    <select id="b" name="yyy">       <option ... </option>    </select> </td>  ... etc. 

when select box option changed, how can use jquery return id of select box , td?

i think should like:

$(document).ready(function() {      $('select').change(function() {      var id = $(this).attr('id');     return false;      }); }); 

working fiddle

you can use on function change event , find td using closest

$(document).ready(function() {         $('select').on('change',function() {              var id = $(this).attr('id');             var tdid = $(this).closest('td').attr('id');             return false;          }); }); 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -