jeudi 14 janvier 2021

(Javascript) Problem with my if statement to make image larger again. Details:

I am using Javascript and there is an image on my site that becomes larger when clicked on. I need an if statement that makes it smaller again when it’s clicked on again.

I am using HTML, CSS and Javascript.

0)Image is small 1)Image becomes large when clicked on 2)Image becomes smaller if clicked on again

I am having trouble with #2.

Here is my code:

if (thumbnailElement.className == "")
    {
    thumbnailElement.addEventListener("click", function()
    {
    thumbnailElement.className = "small"; });
    }
    else {
    thumbnail.Element.className=="";
     }

picture of code in behavior. js file

Aucun commentaire:

Enregistrer un commentaire