Exercise Set 6

Exercise 6 of 6

Show the image source when the images are clicked. Look at the last exercise.

HTML

<img src="/img/cat.png" id="image1">
<img src="/img/dog.png" id="image2">
<img src="/img/wolf.png" id="image3">
<p id="imageSourceParagraph"></p>

JavaScript

var image1 = document.getElementById("image1");
var image2 = document.getElementById("image2");
var image3 = document.getElementById("image3");
var imageSourceParagraph = document.getElementById("imageSourceParagraph");

image1.addEventListener("click", showImageSource);
image2.addEventListener("click", showImageSource);
image3.addEventListener("click", showImageSource);

function showImageSource() {
    // your code will appear here
}

You must be signed in to type your code.

Show your answers to the instructor before moving on.

Last exercise Next topic First exercise