How can I always extract the number 11 in all these cases.
id="section-11"
id="test-11"
id="something-11"
I do $(this).attr('id');
then what do I do next?
Many ways to achieve that, one way is to use .split()
like:
var id = "section-11";
var number = id.split(/-/)[ 1 ];
alert( number ); // 11
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With