>')") What is the best way to select an element that does not contain a number? eg, $('div').not(":c...">

Jquery.not (": contains ('<< any number >>')")

What is the best way to select an element that does not contain a number?

eg,

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

Sorry, I didn’t formulate my example correctly.

I have already collected about 20 sections, and you then need to filter out those that do not contain numbers in order to pass them to the function.

I tried gettin your example work like

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

but no luck

+6
source share
2 answers

Without using a plugin, you can simply use a filter.

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

Evidence

+7
source

Instead of pretending to be all with selectors, you can use .filter() .

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

Demo: http://jsfiddle.net/mattball/3sRmt/

+3
source

Source: https://habr.com/ru/post/887730/


All Articles