var rows = $(".sometable tr:last");
var cells = $(".sometable tr:last td").filter(function() { return $(this).html().length == 0 });
I want to get the first empty cell in the last row of my table.
The table is rendered from the server and it is html table. I can iterate to cells and get the first cell if there are elements available. But I do not want to do that.
Is there any other way without looping? After getting first element i want to call jquery .html(‘set’) method to set some html data.
However,
:lastand:firstare non-standard jQuery-specific selectors which means you won’t get the benefit of fast native selectors. Also, you’re going to have trouble if there can be nested tables.If you make sure you’ve got a
<tbody>around the rows in your markup (for XHTML and browser fixup compatibility), you could better say: