JQuery | noop() method
Last Updated :
27 Apr, 2020
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 >
</ 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 >
</ 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:
Share your thoughts in the comments
Please Login to comment...