I’m using gt() to add columns to a table.
I need to use the row number and the column number to build the cell id.
Getting the column number is straightforward:
var c = $("#gridLayout tr:first td").length;
but how can I get the current index from gt() for the row number?
$("#gridLayout tr:gt(0)").append('<td>.......</td>');
One way would be to use the built in index parameter for
.each().This lets you get an index number without having to call another method.
Try it out: http://jsfiddle.net/8V4AY/
If you were going to skip the first row:
you could adjust the
idxby 1 if you needhttp://jsfiddle.net/8V4AY/1/