Reputation: 11652
I have an image without class
and id
, just src
exists. I want to empty the src
attribute.
<td class="ms-vb" style="padding-bottom: 5px;">
<img alt="" src="/_layouts/images/square.gif"/>
<td>
to
<td class="ms-vb" style="padding-bottom: 5px;">
<img alt="" src=""/>
</td>
I need to find this image among several images in HTML. How to do that?
Upvotes: 0
Views: 2207
Reputation: 8814
$('img[src="/_layouts/images/square.gif"]').each(function(){
$(this).attr("src","");
});
Anyway, @kingjiv is right, is better for you to remove it entirely:
$('img[src="/_layouts/images/square.gif"]').each(function(){
$(this).remove();
});
Upvotes: 1
Reputation: 98
You can also use the parent class :
$('td.ms-vb img').attr('src','');
Upvotes: 0
Reputation: 43823
$('img').each(function() {
$(this).attr('src', '');
});
will empty all src
. You can change the first selector to suit your needs.
Upvotes: 2
Reputation: 28906
$( "img[src='/_layouts/images/square.gif']" ).attr( 'src', '' );
Upvotes: 1