Reputation: 53
i have element div with id="akbarslide"
. There are four images inside.
<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" />
I tried the code below, but images weren't removed.
$('img[src="garbage.jpg"]').remove();
Upvotes: 0
Views: 9516
Reputation: 148150
You can not use exact match as the src is not garbage.jpg
but have to use Attribute Ends With Selector, $ or contains garbage.jpg
Use *
for Attribute contains selector
$('img[src*="garbage.jpg"]').remove();
If you are certain that the src endwith garbage.jpg, you can use $
$('img[src$="garbage.jpg"]').remove();
Upvotes: 3
Reputation: 667
try:
$('img[src$="garbage.jpg"]').remove();
It will find the image whith the src
ends with garbage.jpg
Upvotes: 1
Reputation: 41605
You can do it with this:
$("img[src$='garbage.jpg']").remove();
Living demo: http://jsfiddle.net/D9Hxk/
Upvotes: 1