MartinStettner MartinStettner - 2 years ago 104
Javascript Question

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

is there a way to directly select all 'inner' table cells (

elements) of a table (i.e. all cells except the ones in the first and last row and column) using a jquery selector expression?

Answer Source

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)')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download