0

我有元素 div id="akbarslide"。里面有四张图。

<img src="image_suspetio/garbage.jpg" alt="garbage.jpg" width="270" height="250" />
<img src="image_suspetio/dog.jpg" alt="dog.jpg" width="270" height="250" />
<img src="image_suspetio/bar.jpg" alt="bar.jpg" width="270" height="250" />
<img src="image_suspetio/sky.jpg" alt="sky.jpg" width="270" height="250" />

我尝试了下面的代码,但图像没有被删除。

$('img[src="garbage.jpg"]').remove();
4

4 回答 4

3

您不能使用完全匹配,因为 src 不是garbage.jpg,但必须使用Attribute Ends With Selector、$或 containsgarbage.jpg用于Attribute 包含选择*

$('img[src*="garbage.jpg"]').remove();

如果您确定 src 以垃圾.jpg 结尾,则可以使用$

$('img[src$="garbage.jpg"]').remove();
于 2013-07-04T16:33:39.403 回答
1

你可以这样做:

$("img[src$='garbage.jpg']").remove();

现场演示:http: //jsfiddle.net/D9Hxk/

于 2013-07-04T16:34:34.977 回答
1

尝试:

$('img[src$="garbage.jpg"]').remove();

它会找到以src结尾的图像garbage.jpg

于 2013-07-04T16:34:35.540 回答
1
 $("#akbarslide img[src*='image_suspetio/garbage.jpg']").remove();
于 2013-07-04T16:35:10.713 回答