I’m writing jQuery code where I need to check if link is an image. Currently code looks like this:
$('a[href$=".png"]').click(function() {
// do something smart
});
Is it possible to have an array of attributes in the code, to check for multiple formats, something like this:
$('a[href$=.jpg],a[href$=.jpeg],a[href$=.png]').click(function() {
// do something even smarter
});
What is the best practice here? Thanks!
Yes you can do that.
That is perfectly legal.
What you can do also is check on click what the href is: