What I've been trying is to hover an HTML element via jQuery/JavaScript.
Here we have an <a>
, which reads "Beer".
This will have an underline when the mouse pointer is hovering it in the following way.
The line is created of the :before
selector.
I'm wondering if it's possible to hover any of those <a>
with JS, so that one of those <a>
is hovered without the user actually hovering it.
Any advice will be appreciated.
Just in case, here is CSS which created the underline. I made this by referring to this tutorial.
.nav-link{
position: relative;
text-decoration: none;
}
.nav-link:before {
content: "";
position: absolute;
width: 100%;
height: 2px;
bottom: 0;
left: 0;
background-color: white;
-webkit-transform: scaleX(0);
transform: scaleX(0);
-webkit-transition: all 0.3s ease-in-out 0s;
transition: all 0.3s ease-in-out 0s;
}
.nav-link:hover:before {
-webkit-transform: scaleX(1);
transform: scaleX(1);
}