Jquery:选择具有特定来源的图像?

时间:2022-11-13 15:39:16

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:

我想使用jquery选择具有特定源的所有图像并将工具提示应用于它们。当我找到带有类的目标时,我的工具提示工作正常,但我认为当我应该能够选择具有已知img源的所有图像时,它会更有效并避免添加不需要的类。我认为应该运行的代码是:

$("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:

使用Firebug的Dom检查器,img元素具有以下来源:

"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.

我已经四处乱窜,选择它的各种浪潮,这让我感到很震惊。任何帮助将不胜感激。

2 个解决方案

#1


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

呃......问题是资本化!将其更改为:

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

Now it works fine. Please ignore my stupidity.

现在它工作正常。请忽略我的愚蠢。

#2


If you'd like a case-insensitive selector this question might be helpful:

如果你想要一个不区分大小写的选择器,这个问题可能会有所帮助:

Is there a case insensitive jQuery :contains selector?

是否有一个不区分大小写的jQuery:包含选择器?

#1


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

呃......问题是资本化!将其更改为:

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

Now it works fine. Please ignore my stupidity.

现在它工作正常。请忽略我的愚蠢。

#2


If you'd like a case-insensitive selector this question might be helpful:

如果你想要一个不区分大小写的选择器,这个问题可能会有所帮助:

Is there a case insensitive jQuery :contains selector?

是否有一个不区分大小写的jQuery:包含选择器?