Reputation: 136
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!
Upvotes: 3
Views: 300
Reputation: 82241
For getting td elements that have numeric value in it:
$(".numbers").filter(function(){
return $.isNumeric($(this).text());
});
Upvotes: 5