Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery: Selecting images with a specific source?

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.

like image 597
Ryan Avatar asked May 18 '09 15:05

Ryan


People also ask

How to select all input elements with type=”image” in jQuery?

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 −

What is image selector in jQuery?

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 do I change the source of an image in jQuery?

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)

What are jQuery selectors?

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.


1 Answers

Ugh... The issue was capitalization! Changed it to:

$("img[src*='Phone']")

Now it works fine. Please ignore my stupidity.

like image 104
Ryan Avatar answered Sep 30 '22 20:09

Ryan