Hi all how can i check If clicked img src contains specific text if then do some functions?
Example:
<img src="file:///C:/path/img4-dog.jpg">,
<img src="file:///C:/path/img4-cat.jpg">
run alert if clicked img src contains 'dog' something like that?
$('img').click(function(){
if (this.src.indexOf("dog") != -1)
alert('contains dog');
})
$('img').click(function(e) {
if ($(this).attr('src').indexOf('dog') != -1) {
alert('this contains dog');
}
});
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