2011-05-10 46 views
6

選擇不包含數字的元素的最佳方法是什麼?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 { 

工作,但有沒有運氣

回答

7

,不使用插件,你可以使用過濾器。

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

Proof

相關問題