+ 2
how would you write a code that shows or hides an image on a page when the user clicks something?
I want to have images on the page, and let the user click a <button> to show or hide the image. (using HTML, CSS, and javascript). thank you for your help
4 Respostas
+ 7
btn.onclick = function() {
if(img.style.display = "none") {
img.style.display = "block";
} else {
img.style.display = "none";
}
}
This makes the job, where img is the image element selected with DOM and btn the button selected with DOM...
+ 7
You can use Javascript for that..
When user clicks button img.style.visibility=“hidden“;
Something like that.. 😅
+ 2
if you want that the area the element occupies before not to cgange, you can use opacity: 0%;
0
hmm am here.......?