Skip to content
Advertisement

Show hidden button on mouseover/ mouseout with vanilla JS

I want the button near the homer class to be invisible. It should be visible only on mouseover, what’s wrong with my code?

By default, it is visible, and when I mouseover for the first time it inserts visibility: visible. When I mouse-out for the first time, it disappears.

But nothing happens when I mouseover again. I need a solution in Vanilla JS.

Here is the code:

JavaScript
JavaScript
JavaScript

Advertisement

Answer

It can’t react to the event being hidden (not present), here is an option using opacity:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement