Sindar
Sindar

Reputation: 10839

Dynamically change an image on a web page

I’m having some difficulties trying to dynamically change an image.

<a href="#no-reload" id="dropMenuButton49" class="dropMenuButton">
<input id="searchEngineImage" type="image" src="http://example.com/image.php?i=yahoo-icon.png">
<input type="image" src="images/down.png" name="dropDown">
</a>

I need to change the first one: http://example.com/image.php?i=yahoo-icon.png.

Is this possible with jQuery or something else?

Upvotes: 1

Views: 165

Answers (3)

Naoise Golden
Naoise Golden

Reputation: 8913

$('#searchEngineImage').attr('src', "http://some.other/image.png");

Upvotes: 0

Ramos
Ramos

Reputation: 41

Yes , you can change it dynamically by jquery... Check this:

http://api.jquery.com/attr/

Upvotes: 0

Andy
Andy

Reputation: 30135

$('#searchEngineImage').attr({'src':'some-image.jpg'});

Upvotes: 4

Related Questions