Teifion
Teifion

Reputation: 111109

Jquery, alter image

I know that I can use $('#myId').load('aPage.html'); to load a page into an element, how do I do use that to alter an image?

Upvotes: 1

Views: 377

Answers (2)

matdumsa
matdumsa

Reputation: 16105

$("selectorforyourimage").attr("src","newimagelocation");

Upvotes: 6

pihentagy
pihentagy

Reputation: 6285

Note, that the image will load no sooner, than you load it, so you may want to preload it.

For this, you can use this plugin or this mini-plugin

Upvotes: 1

Related Questions