There is a class that is being added to the li on hover in this fiddle.
I want to be able to add a class to the first li if the last li has the .on class applied to it. I have tried something like this but it doesn’t seem to work?
if ($("li.top-level:last").contains(document.on))
{
$('li.top-level:first').addClass('first');
}
Updated fiddle with suggested answer.
Demo based on your fiddle
jQuery doesn’t have a
.contains()method; but it does have a.hasClass()method (which does what the name suggests):