Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/462.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如果td包含不仅在IE中工作的文本,则删除tr_Javascript_Jquery_Html_Internet Explorer_Html Table - Fatal编程技术网

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

Javascript 如果td包含不仅在IE中工作的文本,则删除tr,javascript,jquery,html,internet-explorer,html-table,Javascript,Jquery,Html,Internet Explorer,Html Table,以下是HTML: var searchString = 'teststring'; $("td").each(function() { if ($(this).text() == searchString) { $(this).parent().remove(); } }); 测试字符串 B C 上面的脚本我正在使用它删除tr,如果任何td有匹配的文本。由于某些原因,它在IE(所有版本)中无法工作,在所有其他浏览器中也可以正常工作 有人知道原因吗?不确定您使

以下是HTML:

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

测试字符串
B
C
上面的脚本我正在使用它删除
tr
,如果任何td有匹配的文本。由于某些原因,它在IE(所有版本)中无法工作,在所有其他浏览器中也可以正常工作


有人知道原因吗?

不确定您使用的是哪款ie浏览器。无论如何,这段代码将对您有所帮助。在ie10中测试

<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>

在演示中使用setTimeout

不是答案,而是建议停止使用IE或为IE设置例外。作为开发人员,请注意,您不支持IE,因为它不符合web标准。您也可以共享html示例。。还有哪个IE版本…可能是有前导/尾随空格。。。因此,请尝试
$.trim($(this).text())==searchString
-工作fine@ArunPJohny谢谢你,阿伦,我试试那件饰件。
var searchString = 'teststring';
$("td").each(function() {
    if ($(this).html() == searchString) {
        $(this).parent().remove();
    }
});