表单元格的JQuery选择器,除了第一行/最后一行/列

有没有办法使用jquery选择器表达式直接选择表的所有“内部”表格单元格(

元素)(即除了第一行和最后一行和列中的所有单元格)?

你可以使用:not():first-child:last-child选择器,就像这样

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

要排除第一行/最后一行:

 $('table tr:not(:first-child, :last-child) td:not(:first-child, :last-child)') 
  $('#table_name tr td:not(:first-child)').each(function () { $(this).html(''); }); 

这里的示例如何跳过表的第1个td(table_name).U可以写:last-child跳过最后一个td来执行某个任务。