Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery selector for table cells except first/last row/column

is there a way to directly select all 'inner' table cells (<td> elements) of a table (i.e. all cells except the ones in the first and last row and column) using a jquery selector expression?

like image 723
MartinStettner Avatar asked Oct 26 '10 20:10

MartinStettner


People also ask

How to get last row index of table in jQuery?

Use find() method to find the all table rows of the table. Use last() method to get the last row of table.

How we can delete all table rows except first one using jQuery?

The jQuery function removes all the rows except the first one using the remove() method. Syntax: $('#btn').


1 Answers

You can use :not() with the :first-child and :last-child selectors, like this

$('table td:not(:first-child, :last-child)') 

To exclude first/last rows as well:

$('table tr:not(:first-child, :last-child) td:not(:first-child, :last-child)') 
like image 106
Nick Craver Avatar answered Oct 07 '22 17:10

Nick Craver