Remove next row cell if rowspan is found

后端 未结 1 495
甜味超标
甜味超标 2021-01-29 10:02

I have to loop through table in every tr if td have csstdgreen and have attribute rowspan. I have to remove cell have text Remove Me.

   function clearTable()         


        
1条回答
  •  不思量自难忘°
    2021-01-29 10:26

    $('table tr').each(function(){
    
        var indexofThis,indexofColSpan,numRows;
        if($('td[rowspan]',this).length!=0)
        {
                indexofThis =$('table tr').index(this);
                indexofColSpan = $('td',this).index($('td[rowspan]',this));
                numRows = $('td[rowspan]',this).attr('rowspan');
    
                $('table tr:gt('+indexofThis+')').each(function(){
                $('td:eq('+indexofColSpan+')',this).remove();
    });
        }
    });
    ​
    

    this should give you a helping hand to get what you need. JS fiddle is not working for me atm. there is a little tinkering to do as it does not do the number of rows, so it will do the whole grid. but this is the main part done.

    0 讨论(0)
提交回复
热议问题