jQuery remove HTML table column

后端 未结 11 1412
粉色の甜心
粉色の甜心 2020-12-13 07:13

I have a HTML table like this:

DE
11条回答
  •  青春惊慌失措
    2020-12-13 08:17

    After a few years, it's probably time to update the answer on this question.

    // Listen for clicks on table originating from .delete element(s)
    $("table").on("click", ".delete", function ( event ) {
        // Get index of parent TD among its siblings (add one for nth-child)
        var ndx = $(this).parent().index() + 1;
        // Find all TD elements with the same index
        $("td", event.delegateTarget).remove(":nth-child(" + ndx + ")");
    });
    

提交回复
热议问题