You only need :hover pseudo-class for this , when you exit an element, it will return to it by default not :hover , for example:
.class { color: black; } .class:hover { color: red; }
when you hover, the color will be red, and when you "mouseout", the color will return to black because it will no longer match the :hover selector. This is the default behavior for all browsers, nothing special you need to do here.
If you want to do something software, you are looking for a mouseout JavaScript event .
source share