I have a bunch of anchor tags inside a #container
. I am selecting a random anchor tag with jQuery and adding an .active
class to it.
Then, when a user hovers over any of these anchor tags, the .active class gets removed from the one that currently has it:
$("#container").find("a").eq(random).addClass("active");
$("#container a").hover(function() {
$("container a.active").removeClass("active");
});
I want to add one more thing to this. If a user hovers NOT over any of the links inside the #container
, I want to add the .active
class again to any random anchor tag inside the #container
. How can I do that?