I am trying to write a script that will find all <a> tags whose target is either a jpg, gif, or png and attach a function to them.
$('a')
.filter(function(){
return this.href.match(/*probably some regex here?*/)
})
.bind('mouseover', function(){
alert('foo');
})
This should work, but I don't know what the regex would look like. If there's a better way, please let me know that as well. Thanks!
You almost had it!!!
$('a[href]').filter(function() {
return /(jpg|gif|png)$/.test($(this).attr('href'))
}).bind('mouseover', function(){
alert('foo');
})
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