-1

I am a javascript beginner.

function PlayPause() {
if (playing) {
    playing = false;
    v*****s.pause();
} else {
    playing = true;
    v*****s.play();
}
};

what I want is add a line which change the source of an image in my html code. do exist something like this

function PlayPause() {
if (playing) {
    playing = false;
    Vianeos.pause();
    src="img_1"
} else {
    playing = true;
    Vianeos.play();
    src="img_2"
}   
};

I hope that you understand what I mean. if need to be more explicit just ask me :)

victorfau
  • 45
  • 1
  • 4
  • 18

2 Answers2

1

Add id to you image element in html :

<img src = "anything" id= "myImage" >

then update it from you function in javascript :

function PlayPause() {
var imageElement = document.getElementById("myImage");

if (playing) {
    playing = false;
    Vianeos.pause();
    imageElement.src="img_1"
} else {
    playing = true;
    Vianeos.play();
    imageElement.src="img_2"
}   
};
Ali Ezzat Odeh
  • 2,093
  • 1
  • 17
  • 17
0

var imgEle = document.getElementById("imgtag"); imgEle.src="anything";

Kunal Bhatia
  • 711
  • 5
  • 10