0

I have a dialog in jQuery and I want to show the dialog when the document loads. But I don't want to put code in <body onload="showdialog();">. I want to put javascript in the main div or the footer div that works like onload in the body event. Any way to do this?

<body onload="$('#dialog').slideDown('slow');">
 <div id="dialog">Dialog</div>
 <footer></footer>
</body>

I want this:

<body>
 <div id="dialog">Dialog</div>
 <script> show dialog code in load page </script>
 <footer>
 // or this place =>
 <script> show dialog code in load page </script>
 </footer>
</body>
dda
6,2212 gold badges28 silver badges37 bronze badges
asked Nov 20, 2012 at 13:35
1
  • 1
    That is the purpose of $(document).ready(). Put it wherever you wish. Commented Nov 20, 2012 at 13:37

1 Answer 1

5

You want to take a look at the ready function, like so:

$(document).ready(function() {
 $('#dialog').slideDown('slow');
});
answered Nov 20, 2012 at 13:38
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.