John Magnolia
John Magnolia

Reputation: 16793

If there are no submenus with a class of in, add a class to the first one

This works if there is no submenu with a class of in, but on another page which has a submenu with a class in this script still runs.

$(".nav-submenu").not(".in").eq(0).addClass("in");

Upvotes: 1

Views: 34

Answers (1)

nice ass
nice ass

Reputation: 16719

if(!$(".nav-submenu.in").length)
  $(".nav-submenu").eq(0).addClass("in");

Upvotes: 1

Related Questions