I want to have an image such as this and when I click it, I want to show an HTML element such as
<input type="radio"></input>
<input type="radio"></input>
I want to be able to toggle the element to show and hide by pressing the image. How can I do this?
3
Answers
Below snippet can give you an idea of what you can do.
You can solve that with create
onclick
event on that image element. Try this :Create an eventListener on the image and pass in the event to use for reference in the DOM, then you can create and add any HTML using
innerHTML
.Or you could toggle a class that hides the element you wish to show by default, then toggle it using
el.classList.toggle()
.