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>
1 Answer 1
You want to take a look at the ready function, like so:
$(document).ready(function() {
$('#dialog').slideDown('slow');
});
Sign up to request clarification or add additional context in comments.
Comments
default
$(document).ready(). Put it wherever you wish.