I have a large table, and I need to be able to select a specific cell using it\'s cell/row coordinates.
What\'s the most elegant way of doing this using jQuery?
This is one case where I think using native JavaScript actually makes the code easier to understand:
var table = $("#table")[0];
var cell = table.rows[1].cells[1]; // This is a DOM "TD" element
var $cell = $(cell); // Now it's a jQuery object.
Note that just selecting the table
element will make rows
include those rows in your thead
(and tfoot
). What you probably want is:
var table = $("#table tbody")[0];
/* remaining code from above */
Here's an example: http://jsfiddle.net/CgqQt/