1
Hi, I’m setting up a small site where I wanted to use various images as button that when clicking each one display a different text, how can I do this?
I tested this one but it doesn’t close the first text when opening the second, it gets all mixed up in the same space.
<div class="divspoiler">
<input type="image" src="IMAGEM AQUI" onclick="if (this.parentNode.nextSibling.childNodes[0].style.display != '') { this.parentNode.nextSibling.childNodes[0].style.display = ''; this.value = 'Ocultar'; } else { this.parentNode.nextSibling.childNodes[0].style.display = 'none'; this.value = 'Mostrar'; }" />
</div><div><div class="spoiler" style="display: none;">TEXTOOOOOO
</div></div>
" closes the first text when opening the second" where is the second text ? I only see one in the question
– Isac
Use jquery to make it easy, you can learn more in w3schools. search for selectors here and about events here
– PV Telles
Opa I hosted the site for you to see how this http://digimonworld1.000webhostapp.com/ the buttons I made so far are the first two pets in the pink column, I wanted the text to disappear by clicking anywhere else on the page, without having to click on the pet again.
– Marcelo C.
I suggest you try to reproduce the same problem here by reducing it to the minimum necessary, because what you have in question seems a little different from what is on your site
– Isac