jquery .not(“:contains('<>')”)

jquery .not(“:contains('<<any number>>')”)

问题描述:

选择不包含数字的元素的最佳方法是什么?jquery .not(“:contains('<<any number>>')”)

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

对不起乍得我有我的措辞例如错误的。

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

我试图刚开您的例子就像

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

工作,但有没有运气

,不使用插件,你可以使用过滤器。

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

Proof

而是让所有花哨选择,你可以使用.filter()

var re = /\d+/; 

var $noNumbers = $('div').filter(function() 
{ 
    return !$(this).text().match(re); 
}); 

演示:http://jsfiddle.net/mattball/3sRmt/