I am trying to create webpage where the user clicks a button and then the page displays images saved in an array.When I run the code, It displays the source of the images, but not the images. Any tips on what I am doing wrong? Thanks in advance
<!DOCTYPE html>
<html>
<body>
<h1>Slideshow</h1>
<p>Holiday Slideshow</p>
<button type="button" onclick="beginShow()">View Slideshow</button>
<p id="p1"><img id="pic1" src="./assets/pic1.jpg">
Click on "View Slideshow". Click to display slideshow</p>
<script>
var list = [
"/assets/pic1.jpg",
"/assets/pic2.jpg",
"./assets/pic3.jpg",
"./assets/pic4.jpg"
];
var index = 0;
function beginShow() {
setTimeout(myTimeout1, 2000)
setTimeout(myTimeout2, 4000)
setTimeout(myTimeout3, 6000)
setTimeout(myTimeout4, 8000)
}
function myTimeout1() {
document.getElementById("p1").innerHTML = list[0];
}
function myTimeout2() {
document.getElementById("p1").innerHTML = list[1];
}
function myTimeout3() {
document.getElementById("p1").innerHTML = list[2];
}
function myTimeout4() {
document.getElementById("p1").innerHTML = list[3];
}
</script>
</body>
</html>
srcofpic1document.getElementById("pic1").src=list[x]