LearnFast.Ninja

jQuery onload event function ready event handler example

Write the document.ready function using jQuery. Implement the Show_Alert function. Copy the Working example. Note you can use this function several times.

Step 1: Write the document.ready function using jQuery. 
$("document").ready(Show_Alert());
 
Step 2: Implement the Show_Alert function. 

function Show_Alert() {

    alert("The page loaded.");

}

 
Step 3: Working example. 

<html>

<head>

    <title>jQuery onload example</title>

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.js"></script>

 

    <script type="text/javascript">

        $("document").ready(Show_Alert());

 

        function Show_Alert() {

            alert("The page loaded.");

        }

    </script>

</head>

<body>

    Some text...

</body>

</html>

 
Result:


Tags

jquery

jquery-tutorial-for-beginners jquery-ready-function