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

后端 未结 2 1218
一个人的身影
一个人的身影 2021-02-02 09:52

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

相关标签:
2条回答
  • 2021-02-02 09:57
     $('#table_name tr td:not(:first-child)').each(function () {
                        $(this).html('<input type="text" value="' + $(this).html() + '" />');
                    });
    

    Here example how to Skip 1st td of a table(table_name) .U can write :last-child to skip last td to do some task.

    0 讨论(0)
  • 2021-02-02 10:07

    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)')
    
    0 讨论(0)
提交回复
热议问题