如果找到rowspan,则删除下一行单元格 [英] Remove next row cell if rowspan is found
问题描述
如果td具有csstdgreen并且具有属性rowspan,我必须在每个tr中循环查看表。
我必须删除单元格才能删除我。
$ p $
函数clearTable()
{
if($(tr)。has(td如果($('td [rowSpan]')== 1 || $('td [rowSpan]')== 2 || $ ('td [rowSpan]')== 3)
{
var $ this = $(this);
var i = $ this.index();
$('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:'('+ indexofThis +')')。each(function(){
$('td:eq('+ indexofColSpan +')',this).remove();
});
}
});
这应该可以帮助您获得所需的东西。 JS小提琴不适合我atm。
有一点修补功能,因为它不会执行行数,所以它会执行整个网格。但这是完成的主要部分。
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()
{
if ($("tr").has("td.csstdgreen").length > 0)
{
if ($('td[rowSpan]') == 1 || $('td[rowSpan]') == 2 || $('td[rowSpan]') == 3)
{
var $this = $(this);
var i = $this.index();
}
}
}
$('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.
这篇关于如果找到rowspan,则删除下一行单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!