Adam Adam - 1 year ago 46
jQuery Question

JQUERY + Find all <img> with an empty src tag

I have a number of questions users answer. An unanswered question will have a blank source like shown below:

<img src="" id="joinEmailResponse" class="joinResponse" alt="...">

I need to be update all empty src tags with 'images/redcross.jpg' and make them visible .show();

I'm toying with the following code but its not something I done much off:

var notAnswered = $('img.joinResponse').filter('[src=""]');

Not sure if I'm on the right track or how I would then update the src and visibility.
Would I then loop through the results or can I change the 2 modifications.

Any advise would be greatly appreciated.



try this

$('img.joinResponse[src=""]').attr("src", "images/redcross.jpg").show();