Select a button with a class inside of a table with an id
html, jquery
Solution
all your selectors seem ok. (Here is a working jsFiddle)
I see two possible issues:
Either your data is added dynamically, in which case you need to use event delagation using `.on()`:
$(document).on("click",'#my_table .btn_save',function(){
//what you're doing
});
The other possibility is that the selector is added before the data, in which case you need to put your statement in a `$(document).ready` clause
$(function(){
$('#my_table .btn_save').click......
});
Problem
I have the following code: ``` <table id="my_table"> <tr> <td> <button class="btn_save" value="1">Save</button> </td> </tr> </table> ``` I want to select that button I have tried: ``` $('#my_table .btn_save').click...... $('table#my_table .btn_save').click...... $('table td .btn_save').click...... $('table td :button.btn_save').click...... ``` nothing seems to work, what am I missing? btw, I cant put an id on the button because this will be a dynamycally generated table with lots of buttons, thats why I chose the class way.