Reputation: 7882
How can I extract (with jQuery) the numbers from this a href Tags?
<a href="#slide1"></a>
<a href="#slide2"></a>
<a href="#slide3"></a>
Thanks a lot for help.
Upvotes: 0
Views: 77
Reputation: 2150
Try this
$('a').each(function() {
alert($(this).prop('href').replace(/[^\d]+/, ''));
});
Upvotes: 0
Reputation: 9370
$('a').each(function(){
alert($(this).prop("href").replace("#slide",""));
});
Upvotes: 1
Reputation: 20250
Something like this should work:
$('a').each(function() {
alert($(this).prop('href').replace(/[^\d]+/, ''));
});
Upvotes: 3