JQuery dialog momentairly displayed on page load

You can add some CSS so it’s by default hidden, no onload code needed:

#myDialog { display: none; }

With this, no other code is necessary, when you open the dialog it’ll reverse this style…so nothing additional to run on document.ready. Alternatively, if you have lots of dialogs, give it a class, like this:

<div id="myDialog" class="dialog"></div>

With this CSS:

.dialog { display: none; }

In almost all cases, jQuery uses the display style attribute to hide things, so using this to initially hide something will work with whatever you want to use the element for later, whether it’s a dialog, a simple .fadeIn(), etc.

Leave a Comment