I have a list of results, and I added an hover event to it using jQuery, so the title will be colored red.
It works just fine.
<li><a class="hoverbox"></a><h1 class="ttl">Result 1</h1></li>
<li><a class="hoverbox"></a><h1 class="ttl">Result 2</h1></li>
<li><a class="hoverbox"></a><h1 class="ttl">Result 3</h1></li>
$(document).on({
mouseenter: function () {
$('.ttl').css("color","red");
},
mouseleave: function () {
$('.ttl').css("color","inherit");
}
}, ".hoverbox");
The thing is whenever I do mouseover on a single element, all of the elements turn red. I want only the specific element to go red.
I tried using jQuery's each() but couldn't wrap my head around how to use it with the given syntax.