-2

I have an image in my div:

<div class="pressphone">
    <img class="phone" src="../img/template/iphone3.png">
</div>

how can I switch the photo to ../img/template/iphone4.png from javascript/jquery?

user3766930
  • 5,629
  • 10
  • 51
  • 104

1 Answers1

2
$("img.phone").attr("src", "../img/template/iphone4.png");

Note that this will replace the source of all images with class phone!

If that is an issue, you should consider to give your image a unique id and change the jquery selector accordingly.

Mike Scotty
  • 10,530
  • 5
  • 38
  • 50