jQuery .ready() function

Use the .ready() function to run a script when the page is “ready” — that is, the DOM (Document Object Model) is fully loaded.

This is significant because many scripts require that the DOM be fully loaded before the script run. Putting a script inside the .ready() function assures us that the script will only run when jQuery detects that the DOM is ready.

Here is a simple demonstration of the .ready() function:

<script language="javascript" type="text/javascript">
jQuery(document).ready(
function () {
alert(‘ready’);
}
);
</script>