Knowledge Walls
Gopal Rao
Mumbai, Maharashtra, India
Passcode:
How to run jquery when page loads in Jquery functions of JQuery Examples
3217 Views
Note 
.ready() function called when the page load completely.

For example, if you not use jquery statements inside the .ready() function the statements run before the page load completely.So that It cause some issues on page.To neglect this problem use .ready function.


Example: 1 Jquery with ready() function
Example: 2 Jquery without ready() function
Example: 1 Jquery with ready() function
<html>

<head>
    <title>HTML-JQuery</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>

    <script type="text/javascript">
        $(document).ready(function () {
            $(".one").hide();
        });
    </script>
</head>

<body>
    <div class="one">one</div>
    <div class="two">two</div>
    <div class="three">three</div>
    <div class="four">four</div>
</body>

</html>
Example: 2 Jquery without ready() function
<html>

<head>
    <title>HTML-JQuery</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>

    <script type="text/javascript">
        $(function () {
            $(".one").hide();
        });
    </script>
</head>

<body>
    <div class="one">one</div>
    <div class="two">two</div>
    <div class="three">three</div>
    <div class="four">four</div>
</body>

</html>
Example: 1 Demo 
Example: 2 Demo  
Next Topics
Next lessons of current book.
Best Lessons of "JQuery Examples"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details