我有一张表,上面有很多 td ".numbers",如下所示:
<tr><td class="numbers">12345</td></tr>
<tr><td class="numbers">6789</td></tr>
<tr><td class="numbers">123%</td></tr>
我只需要选择没有“%”和其他字符的 TD 值。
注意:我无法删除类“numbers”,因为它是自动生成的。
这是行不通的:
$.each($(".numbers"), function( index, value ) {
if ($(".numbers").text().indexOf("%")<0) {
//do stuff
}
}
我如何选择 td 值并使用 indexOf 进行过滤? 谢谢!
最佳答案
获取其中具有数值的 td 元素:
$(".numbers").filter(function(){
return $.isNumeric($(this).text());
});
关于javascript - (jQuery) 将元素选择到 TD 中并过滤仅包含数字的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30305666/