(jQuery) Select item in TD and filter values ​​using only numbers

I have a table with a lot of td ".numbers" something like this:

<tr><td class="numbers">12345</td></tr>
<tr><td class="numbers">6789</td></tr>
<tr><td class="numbers">123%</td></tr>

      

I only need to select TD values ​​without "%" and other symbols.
Note : I cannot remove the "numbers" of the class, because it is automatically generated.

This does not work:

$.each($(".numbers"), function( index, value ) {
    if ($(".numbers").text().indexOf("%")<0) {
    //do stuff
    }
}

      

How can I select td value and filter using indexOf? Thank!

+3


source to share


1 answer


To get the td elements that have a numeric value in it:



$(".numbers").filter(function(){
     return $.isNumeric($(this).text());  
});

      

+5


source







All Articles