bobek
bobek

Reputation: 8020

jquery executing menu loading before the page loads

I have an issue with the menu that I have. It's done in jquery and every time I refresh the page I can see all the levels of the menu, and then it seems like jquery starts working, and menu is formatted to look nice. I was wondering if there is a way to load that jquery before it appears on the screen.

Thank you.

Upvotes: 1

Views: 1100

Answers (3)

jcadcell
jcadcell

Reputation: 811

When you first start building the menu you could set it to be hidden, then as the last step make it visible.

Upvotes: 1

Jason Fingar
Jason Fingar

Reputation: 3372

In my experience, the best solution for this type of issue is to hide the html elements using css (display:none) in your stylesheet. jQuery works by overriding those css attributes on mouse events, so the menu should still function correctly even if the items are hidden initially.

Upvotes: 1

rlemon
rlemon

Reputation: 17666

just set the menu display to none. Then when the page loads use

$(document).ready(function(){
  $("#menu").whatEverPlugin().show();
});

Upvotes: 2

Related Questions