繁体   English   中英

如果td包含仅在IE中不起作用的文本,则删除tr

[英]Removing tr if td contains a text not working only in IE

var searchString = 'teststring';
$("td").each(function() {
    if ($(this).text() == searchString) {
        $(this).parent().remove();
    }
});

这是HTML:

<table>
    <tr>
        <td align="center" width="15%">teststring</td>
        <td align="center" width="15%">B</td>
        <td align="center" width="15%">C</td>
    </tr>
</table>

如果有任何td包含匹配文本,我将使用上面的脚本删除tr 由于某种原因,它无法在IE (所有版本)中运行,并且在所有其他浏览器中都可以正常工作。

有人知道原因吗?

不确定您使用的是哪个浏览器。无论如何,此代码段将对您有所帮助。

var searchString = 'teststring';
$("td").each(function() {
    if ($(this).html() == searchString) {
        $(this).parent().remove();
    }
});

JSFIDDLE中使用setTimeout仅用于演示

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM