I'm currently exploring a method to transform text on my webpage into a divider or new element when clicked. It's a bit difficult to explain, but think of it like an image with a caption underneath - when you click the caption, the image above changes into a box of text, a different image, or a scrollable divider. I'm inspired by the interactive effect on this page, where clicking the skull emoji triggers a new div or image to appear in the box on the left. I've been analyzing the source code and trying to understand how it was achieved, but I'm still unsure.
I attempted to use the onclick guide from w3schools:
<img src="yay.png">
<p id="angelo" onclick="myFunction()">ANGELO</p>
<script>
function myFunction() {
document.getElementById("angelo").innerText = " <div id="info"> Blabla </div> " ;
}
</script>
Although I don't have much knowledge about JavaScript - I've only used it once before! So, following this guide didn't really help me as I tried to figure out a solution. I have a feeling I might be doing it incorrectly.