I know this question sounds odd. Perhaps a button is not the element I’m looking for. What I want to to do is have an element that looks like what I have here:
Now this is technically a button. However, I’d like a small x to pop up in the top right corner when I hover this element so that I can delete the element itself. I have a feel a button is not the way to go here, but I do need an element with an onClick event.
Any pointers would be much appreciated
2
Answers
You can set an onClick event on any HTML elements. You would probably want to add a separate element with the ‘x’ and listen for a click on there.
We can certainly have a button element, add a span element inside (to show x), and only show that span on hover with some javascript, and styling it with css: