Javascript in HTML editor for alternate images in question options | XM Community
Skip to main content

Hi!

In a MC question, I have custom images for each of the 6 options.

Now I want the image to change when clicked on to an alternate image.

All the images are in the library and I have the links.

I know the script should be placed in the HTML editor of the option itself.

This is what I have:

<img src="LINK1" onclick="changeImage(this)">

<script>
function changeImage(img) {
if (img.src === "LINK1") {
img.src = "LINK2";
} else {
img.src = "LINK1";
}
}
</script>

It's not working. Why?

Be the first to reply!

Leave a Reply