Knowledge Walls
Gopal Rao
Mumbai, Maharashtra, India
Passcode:
For loop in jquery example in Jquery functions of JQuery Examples
3575 Views
Syntax
for( initialization;condition;increment(or)decrement)
{
  statements....
  ......
}
Note 
for loop executes upto the condition true.
Example code
<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 () {
            $(".click").click(function () {
                $(".type").empty();
                var count = $("input").val();
                for (var i = 1; i <= count; i++) {
                    $(".type").append(i);
                }
            });
        });
    </script>
</head>

<body>
    <input type="text" />
    <div class="click" style="cursor:pointer;">Enter number in text box then Click here</div>
    <div class="type"></div>
</body>

</html>
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