I've created a table with three rows that can be expanded with the use of an add button. I want to know the index of every row I click. I have a piece of code that works just fine on the three automatically generated rows, but not on the rows I add using the add button.
Here's a fiddle basically shows my issue: http://jsfiddle.net/4wa5kfpz/, my actual code has a lot more stuff in it so this is a basic/stripped version.
As you can see, the rows added between the first two and last do not respond when clicked. I've tried something like (see below, based on this question) to add the click event to the table rows, but that didn't work.
$("table tr").on('click', '#myTable tr', function(e){
alert('Clicked row '+ ($(this).index()+1) );
});
Any ideas?