I use jquery to dynamic create table content in page, how can I get the row number index of this dynamic table? In the following code, when I click the "show more" link, I use index function in following code, but it not work. How to solve this issue? Thanks.
$.getJSON(JsonURL,
function(data){
$.each(data, function(index, item){
var obj = item;
books.push(book);
});
for (var i = 0; i<obj.length; i++) {
var tr=$('<tr></tr>');
$('<td>'+ obj[i].name +'</td>').appendTo(tr);
$('<td>'+ obj[i].category +'</td>').appendTo(tr);
$('<td><a class='showMore' href=#>'+ 'show more' +'</a></td>').appendTo(tr);
tr.appendTo('#tableBody');
};
});
$('a .showMore').on('click', function(event) {
var rowindex = $(this).parent().parent().children().index($(this).parent);
console.debug('rowindex', rowindex);
});