jQuery remove HTML table column

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

I have a HTML table like this:

 element and provide a nice fade effect:

$(document).ready(function(){
    $("a.delete").live("click", function(){
    /* Better index-calculation from @activa */
    var myIndex = $(this).closest("th").prevAll("th").length;
    $(this).parents("table").find("tr").each(function(){
      $(this).find("td:eq("+myIndex+"), th:eq("+myIndex+")").fadeOut('slow', function() {
        $(this).remove();
        fixTitles();
      });
    });
  });
});
function fixTitles() {
  $("tr:eq(0) td").each(function(a){
    $(this).html("Delete Row COL " + (a+1));
  });
}

提交回复
热议问题
DE
11条回答
  •  孤街浪徒
    2020-12-13 08:02

    @Jonathan Sampson's answer, I modified the code to handle table markup containing a