How to get all items from an HTML table with JQuery

April 9th, 2013 by admin Leave a reply »

Here is a little snipped that saved me a lot of manual code writing if you are needing to iterate over a set of rows in a table you have on your webpage. Just simply use the “gt(0)” which according to the JQuery API documentation “select all elements at an index greater than index within the matched set.” Then just pair that with tr: in front of it to select all the table rows of your table and voila, you have all your rows. You can then use the .each method to do the iteration. Don’t forget to change #tableId to whatever you called it in your html, enjoy.

$("#tableId tr:gt(0)").each(function () {
    //perform logic here


Leave a Reply