javascript - Jquery hide span containing certain numbers -


i'm trying perform temporary quick hack on website need hide few spans on page , don't want have go through php remove them permanently. want hide them jquery.

i want use hide() junction hide spans containing number 1 9.

so on page have >>

 <span>good</span>  <span>2</span>    <span>3</span>       <span>4</span>          <span>5</span>              <span>ok</span> 

etc... end 1 ending in <span>bad</span>

i have list of 30 of these, want like:

if span contains number 1-9, hide it. 

i've used hide() function before hide things onclick etc, have no clue how hide if contents equals number, can point me in right direction?

try this: http://jsfiddle.net/ehmjm/

$("span").filter( function() {     var num = number($(this).text());     return num >= 1 && num <= 9; }).hide(); 

or regex: http://jsfiddle.net/ehmjm/2/

$("span").filter( function() {     return $(this).text().match(/^[1-9]$/); }).hide(); 

note: i'm assuming sample dom looking hide spans number in it, if looking hide stuff "i have 5 dogs", you'll need bit different.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -