I need some simple JQuery code so I can change the src value of a specific img.
It’s currently:
<img id="myImage" src="image1.gif" />
and I need to change it to:
<img id="myImage" src="image2.gif" />
using JQuery.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using:
$(function(){ ... });You can use:
to change the image source immediately.
Alternatively, you can use jQuery animations to change an image.
JS
HTML
(Don’t forget to change the CSS of
#id2and putdisplay: noneas initial state).