简体   繁体   中英

(jQuery) Select element into TD and filter values with only digits

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

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

I need to select only TD values without "%" and other chars.
Note : i cannot remove class "numbers" because is automatically generated.

This is not working:

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

How can i select td value and filter with indexOf ? Thank you!

For getting td elements that have numeric value in it:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM