Knowledge Walls
Gopal Rao
Mumbai, Maharashtra, India
If in jquery example in Jquery functions of JQuery Examples
Simple IF statement is used to execute particular statements with certain conditions. It controls the flow of statement execution. If given condition is true then the block of statements will get executed.
if (condition or expression)
Example Hints 
In the following example, If the entered number is less than or equal to 5 then the if condition block executed else the else block executed.
Example code

    <script type="text/javascript" src=""></script>

    <script type="text/javascript">
        $(function () {
            $("div.num").click(function () {
                var a = $("input").val();
                if (a <= 5) {
                    alert("Entered value is less than 6");
                } else {
                    alert("Entered value is more than 6");

    <div>Enter number here</div>
    <input type="text" />
    <div class="num">Click here to run the code</div>

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