Reputation: 1
So I'm trying to do an onclick image change which worked, but I'd like the second image to be bigger than the first, is this possible?
Here is the JavaScript code (this is the first time I'm trying to use HTML aside from basic things)
function changeImage() {
if (document.getElementById("imgClickAndChange").src == "https://cdn.glitch.com/2191cc92-26e9-4b6e-9beb-428fb7eb3976%2FPicsArt_03-26-03.26.33.png?v=1616763476562")
{
document.getElementById("imgClickAndChange").src = "https://cdn.glitch.com/2191cc92-26e9-4b6e-9beb-428fb7eb3976%2FPicsArt_03-26-03.12.37.png?v=1616764012012";
}
else
{
document.getElementById("imgClickAndChange").src = "https://cdn.glitch.com/2191cc92-26e9-4b6e-9beb-428fb7eb3976%2FPicsArt_03-26-03.26.33.png?v=1616763476562";
}
}
I want to be able to change the size of that second image.
Upvotes: 0
Views: 173
Reputation: 144
To change the width and/or height of the image simply use the style property like this:
const myImage = document.getElementById("imgClickAndChange")
myImage.style.width = '500px'
myImage.style.height = '600px'
Upvotes: 1