So I have an issue, when I load a document, I have a class called .active which changes depending on what list item you are viewing using keyboard navigation. The problem is when that list item has the class active assigned to it, I would like that list item only, on hover, to display another piece of content.. But the problem is, I believe, that my hover function is only firing on page load, and only attaching to whatever list item has .active assigned to it on load..
<ul>
<li class="active">Foo <a class="more-info" href="#">Click Me</a></li>
<li>Bar <a class="more-info" href="#">Click Me</a></li>
<li>Pie <a class="more-info" href="#">Click Me</a></li>
</ul>
When a user uses their keyboard navigation the previous list item will not longer have .active and the next one will be assigned the class as follows:
<ul>
<li>Foo <a class="more-info" href="#">Click Me</a></li>
<li class="active">Bar <a class="more-info" href="#">Click Me</a></li>
<li>Pie <a class="more-info" href="#">Click Me</a></li>
</ul>
What I would like to happen is that when a user hovers the new list item, they are presented with the a.more-info but it does not work. I believe again, this is because the .hover(); only runs once on page load and is not listening the whole time..
$("li.active").hover(
function () {
$('li.active a.more-info').fadeIn();
},
function () {
$('li.active a.more-info').fadeOut();
});
Any ideas?