Thursday, 9 June 2022

Parcel won't load images in my javascript file

I am using the parcel bundler for my website.

I've been trying to use gsap to change the src attribute of an <img> tag. This change happens when the user clicks on a <button onclick="changeImage()">. However, the localhost:1234 server doesn't show this change at all. Can parcel change images of my website after build time?

my html snippet:

<img class="mercury_image" src="images/mercury.png"/>
<button onclick="changeImage()"> Click here </button>

my javascript snippet

function changeImage() {
    gsap.timeline()
    .set(".mercury_image", {
       attr: {src: "images/differentImage.png"}
  })
}


from Parcel won't load images in my javascript file

No comments:

Post a Comment