>')")-6ren"> >')")-选择不包含数字的元素的最佳方法是什么? 例如 $('div').not(":contains('1')").not(":contains('2')").not(":contains('3')")...-6ren">
gpt4 book ai didi

jquery .not (":contains(' <<任意数字>>')")

转载 作者:行者123 更新时间:2023-12-03 22:47:47 25 4
gpt4 key购买 nike

选择不包含数字的元素的最佳方法是什么?

例如

$('div').not(":contains('1')").not(":contains('2')").not(":contains('3')")...;

抱歉,乍得,我的示例措辞错误。

我已经选择了大约 20 个 div,然后需要过滤掉那些不包含数字的 div,以便将它们传递到函数中。

我已经尝试让你的示例正常工作

if($(this:+'regex(html, #^0-9]')).length <1 {

但运气不好

最佳答案

无需使用插件,您只需使用过滤器即可。

$('div').filter(function() {
return !/[0-9]/.test( $(this).text() );
});

Proof

关于jquery .not (":contains(' <<任意数字>>')"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5951910/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com