Open In App

JQuery | noop() method

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.




<!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.




<!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:


Article Tags :