Is there a way jquery can only get numbers like how php can get numbers by using (int)?
If I’m trying to get a text that has string and numbers
<div class='selector'>(4)</div>
$('.selector').text().int();
is there anything similar to that where it should obtain only the number 4?
Thanks for your help!
parseInt() should do the trick. Examples (from the linked page):
Of course, you can put variables inside
parseInt()as well as strings.As zerkms says in the comments, you don’t actually need jQuery to do this. JavaScript has more functionality than jQuery would have you believe 😉