jQuery callbacks.lock() Method Last Updated : 23 Jul, 2024 Comments Improve Suggest changes Like Article Like Report The callbacks.lock() method in jQuery is used to lock a callback list in the state. Syntax:callbacks.lock()Return Value: This method returns the callback object to which it is attached. Example 1:This example first adds and fires the function, then locks the callbacks list, and then again adds and fires the function. html <!DOCTYPE HTML> <html> <head> <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.lock() method </p> <button onclick="Geeks();"> click here </button> <p id="GFG_DOWN"></p> <script> let el_down = document .getElementById("GFG_DOWN"); let res = ""; let callbacks = jQuery.Callbacks(); function Geeks() { let func = function (val) { res = res + "value passed is - " + val; }; // Function added to list callbacks.add(func); callbacks.fire("gfg_1"); // Locking the callback list callbacks.lock(); // Function again added to list callbacks.add(func); callbacks.fire("gfg_2"); el_down.innerHTML = res; } </script> </body> </html> Output:Example 2:This example provides a button to lock the list and then add and fire the function to check whether the method is working or not. html <!DOCTYPE HTML> <html> <head> <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.lock() method </p> <button onclick="Geeks();"> click here </button> <button onclick="lock();"> lock here </button> <p id="GFG_DOWN"></p> <script> var el_down = document .getElementById("GFG_DOWN"); var res = ""; var callbacks = jQuery.Callbacks(); function lock() { callbacks.lock(); } function Geeks() { // Function to be added to the list var fun = function (val) { res = res + "This is function and " + "value passed is " + val + "<br>"; }; callbacks.add(fun); // Adding callbacks.fire("GFG_1"); el_down.innerHTML = res; } </script> </body> </html> Output: Comment More infoAdvertise with us Next Article jQuery callbacks.lock() Method P PranchalKatiyar Follow Improve Article Tags : JavaScript Web Technologies JQuery jQuery-Methods Similar Reads JQuery callbacks.locked() Method The callbacks.locked() method in jQuery is used to answer whether the callbacks list has been locked or not.Syntax:callbacks.locked()Return Value: This method returns a boolean value.Example 1: In this example, the callbacks have been locked so the method returns true.html <!DOCTYPE HTML> < 2 min read jQuery callbacks.add() Method The jQuery callbacks.add() method is used to add a callback or a collection of callbacks to a callback list. This method returns the callback object onto which it is attached (this).Syntax: callbacks.add(callbacks)Parameters: callbacks: This parameter holds a function, or an array of functions, that 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.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 Like