jQuery callbacks.empty() Method Last Updated : 23 Jul, 2024 Comments Improve Suggest changes Like Article Like Report The callbacks.empty() method in jQuery is used to remove all the callbacks from a list. It returns the Callbacks object onto which it is attached.Syntax:callbacks.empty()Parameters: It does not accept any parameter.Return Value: This method returns the Callbacks object onto which it is attached.Below examples illustrate the callbacks.empty() method in jQuery:Example 1: In this example, the fun1 function is first added to the callbacks list and all the callbacks present are executed in the list with a given argument. The callbacks.empty() method is executed to empty the list. The second function fun2 is added and the callbacks list is executed again. This demonstrates the emptying of the list after adding the first function. html <!DOCTYPE HTML> <html> <head> <title> JQuery callbacks.empty() method </title> <script src= "https://code.jquery.com/jquery-3.5.0.js"> </script> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksForGeeks </h1> <p> JQuery | callbacks.empty() method </p> <button onclick="Geeks();"> click here </button> <p id="output"></p> <script> var output = document.getElementById("output"); var res = ""; // Initialize a callback list var callbacks = jQuery.Callbacks(); function Geeks() { // First function to be added to the list var fun1 = function (val) { res = res + "This is function 1 and" + " value passed is " + val + "<br>"; }; // Second function to be added to the list var fun2 = function (val) { res = res + "This is function 2 and" + " value passed is " + val + "<br>"; }; // Adding the first function callbacks.add(fun1); // Calling the first function callbacks.fire("GFG_1"); // Clearing the callback list callbacks.empty(); // Adding the second function callbacks.add(fun2); // Calling the first function callbacks.fire("GFG_2"); output.innerHTML = res; } </script> </body> </html> Output: Example 2: This example provides a button to empty the callback list and then add the given function to see the result of emptying the callbacks list. html <!DOCTYPE HTML> <html> <head> <title> JQuery | callbacks.empty() method </title> <script src= "https://code.jquery.com/jquery-3.5.1.min.js"> </script> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksForGeeks </h1> <p> JQuery | callbacks.empty() method </p> <button onclick="Geeks();"> click here </button> <button onclick="empty();"> empty </button> <p id="output"></p> <script> var output = document.getElementById("output"); var res = ""; // Initialize a callback list var callbacks = jQuery.Callbacks(); function empty() { // Clear the callback list callbacks.empty(); } // Function to add and fire callbacks function Geeks() { // Function to be added to the list var fun1 = function (val) { res = res + "This is function 1 and" + " value passed is " + val + "<br>"; }; // Adding the given function callbacks.add(fun1); // Calling the function with value callbacks.fire("GFG_1"); output.innerHTML = res; } </script> </body> </html> Output: Comment More infoAdvertise with us Next Article jQuery callbacks.empty() Method P PranchalKatiyar Follow Improve Article Tags : JavaScript Web Technologies JQuery jQuery-Methods Similar Reads jQuery callbacks.fire() Method The jQuery callbacks.fire() method is used to call all the callbacks with the given arguments in the list. This method returns the callbacks object onto which it is attached (this). Syntax:callbacks.fire( arguments )Parameters:arguments: This parameter defines the argument or list of arguments to pa 2 min read jQuery callbacks.fired() Method The jQuery callbacks.fired() method is used to check if the callbacks have already been called at least once. This method returns the Boolean value.Syntax:callbacks.fired()Parameters: This method does not accept any arguments.Return Value: This method returns a Boolean value.Example 1: This example 2 min read jQuery callbacks.has() Method The callbacks.has() method in jQuery is used to answer whether the list has any callbacks attached. If a callback is passed as an argument, then it answers whether it is on the list or not. Syntax:callbacks.has([callback])Parameters:callback: The parameter defines the callback to search for, in the 2 min read jQuery callbacks.fireWith() Method The callbacks.fireWith() method in jQuery is used to call all the callbacks which are currently in the list with the given context and parameters.Syntax:callbacks.fireWith([context][, params])Parameters:context: This parameter defines the reference to the context in which the callbacks in the list s 2 min read JQuery callbacks.disable() method This callbacks.disable() method in jQuery is used to disable a callback list from doing any other operation further. This method returns the Callbacks object onto which it is attached (this).Syntax: callbacks.disable()There are two examples discussed below: Example: This example disables the callbac 2 min read Like