I want to animate the underscoring of a text. This is no problem with css. However, I want to use another text to trigger the animation of the first text. I already know that you can't use :before in jquery as it's not part of the DOM. I've seen these two threads: Access the css ":after" selector with jQuery and Selecting and manipulating CSS pseudo-elements such as ::before and ::after using jQuery
But I couldn't find any solution that works. Here is the code: https://jsfiddle.net/rbsxufsc/4/
html:
<h2 class='uno'>
<a href=''>:hover, please</a>
</h2>
<h2 class='dos'>
<a href=''>Animate above text</a>
</h2>
css:
h2 > a:before {
content: "";
position: absolute;
width: 100%;
height: 3px;
bottom: 0;
left: 0;
background: #9CF5A6;
visibility: hidden;
border-radius: 5px;
transform: scaleX(0);
transition: .25s linear;
}
h2.uno > a:hover:before,
h2.uno > a:focus:before {
visibility: visible;
transform: scaleX(1);
}
When hovering the first text, it is well animated. When hovering the second text, I want to animate the first text again as if the first text is hovered. Is there any way to do that?