Open In App

JQuery | noop() method

Last Updated : 27 Apr, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
This noop() Method in jQuery is the empty function when user wishes to pass around a function that will do nothing. Syntax:
jQuery.noop()
Parameters: The noop() method does not accept any parameter. Return Value: It returns the undefined. Example 1: In this example, the noop() Method is used with innerHTML function. html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JQuery | noop() method</title> 
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>

</head>
<body style="text-align:center;"> 
    
    <h1 style="color: green"> 
        GeeksForGeeks 
    </h1> 
    
    <h3>JQuery | noop() method</h3>
    <button onclick="geek()">Try it</button>
    <br><br>
    <b> Value Return :</b>
    <br>
    <p id="demo"></p>
 
    <script>
    function geek() {
      var n = jQuery.noop();
      document.getElementById("demo").innerHTML = n;
    }
    </script>
</body>
</html>                                                                                            
Output: Before Click: After Click: Example 2: In this example, the noop() Method is used with alertfunction. html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JQuery | noop() method</title> 
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>

</head>
<body style="text-align:center;"> 
    
    <h1 style="color: green"> 
        GeeksForGeeks 
    </h1> 
    
    <h3>JQuery | noop() method</h3>
    <button onclick="geek()">Try it</button>
    
    <script>
    function geek() {
      var n = jQuery.noop();
      alert("Value Return : " + n);
    }
    </script>
</body>
</html>                                        
Output: Before Click: After Click:

Next Article

Similar Reads