user1670411
user1670411

Reputation: 77

change image with jquery depending on alt tag

I am using an RSS feed to display weather from an external source on my website. I would like to be able to change/swap out the images in the feed for my own images. The only thing that makes each image unique is its Alt tag.

<p>
<b>Tuesday:</b>
<br>
<img alt="Sunny" src="http://www.weather.com.au/images/icons/1.gif">
<br>
Sunny. Warm.
<br>
20 - 28
<br>
</p>

So, is there a way to recognize that the Alt tag is "Sunny", and replace this image with one of my own?

Upvotes: 1

Views: 171

Answers (1)

Madbreaks
Madbreaks

Reputation: 19539

Don't be afraid to reference the manual.

$('img[alt="Sunny"]').attr('src', someUrl); 

Upvotes: 1

Related Questions