I've looked high and low through the docs and internet, and damn if I can't figure this out.
I would like to use jquery to select all images with a specific source and apply a tool tip to them. I have the tooltip working fine when I'm finding the target with classes, but I figured it would be a bit more efficient and avoid adding unneeded classes when I should be able to select all the images with a known img source. The code that I think should work is:
$("img[src*='phone']")
The image tag in the source is:
<img src='images/icons/Phone-32x32.png'>
Using Firebug's Dom inspector, the img element has the following source:
"http://www.deleted.com/v2/images/icons/Phone-32x32.png"
I've dicked around with various waves of selecting it, and it's beyound me. Any help would be greatly appreciated.
The :image selector in jQuery is used to select all input elements with type=”image”. Let us now see an example to implement the :image () selector −
jQuery :imageSelector ❮ jQuery Selectors Example Select <input> elements with type="image": $(":image") Try it Yourself » Definition and Usage The :image selector selects input elements with type=image.
How to Change the Image Source Using jQuery Probably, the best method to change the image sources is jQuery's attr () function. For example, let’s assume your <img> tag has an id attribute of 'your-image', so you can act like this: Watch a video course JavaScript - The Complete Guide (Beginner + Advanced)
jQuery selectors allow you to select and manipulate HTML element(s). jQuery selectors are used to "find" (or select) HTML elements based on their name, id, classes, types, attributes, values of attributes and much more. It's based on the existing CSS Selectors, and in addition, it has some own custom selectors.
Ugh... The issue was capitalization! Changed it to:
$("img[src*='Phone']")
Now it works fine. Please ignore my stupidity.
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