JQuery callbacks.disable() method Last Updated : 24 Jul, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 callback after adding and firing a function. HTML <!DOCTYPE HTML> <html> <head> <title> JQuery | callbacks.disable() 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 id="GFG_UP"> </p> <button onclick = "Geeks();"> click here </button> <p id="GFG_DOWN"> </p> <script> var el_up = document.getElementById("GFG_UP"); var el_down = document.getElementById("GFG_DOWN"); el_up.innerHTML = "JQuery | callbacks.disable() method"; var res = ""; 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>"; }; var callbacks = jQuery.Callbacks(); callbacks.add(fun1); // adding the function 1 callbacks.fire("GFG_1"); // calling the function 1 callbacks.disable(); /*disables further calls to a callback list*/ callbacks.add(fun2); // This will not work. callbacks.fire("GFG_2"); // This will not work. el_down.innerHTML = res; } </script> </body> </html> Output: Example: This example provides a button to first disable the callbacks and then add and fire the method to see the result. HTML <!DOCTYPE HTML> <html> <head> <title> JQuery | callbacks.disable() 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 id="GFG_UP"> </p> <button onclick = "Geeks();"> click here </button> <button onclick = "disable();"> disable </button> <p id="GFG_DOWN"> </p> <script> var el_up = document.getElementById("GFG_UP"); var el_down = document.getElementById("GFG_DOWN"); el_up.innerHTML = "JQuery | callbacks.disable() method"; var res = ""; var callbacks = jQuery.Callbacks(); function disable() { callbacks.disable(); } 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>"; }; callbacks.add(fun1); // adding the function 1 callbacks.fire("GFG_1"); // calling the function 1 callbacks.add(fun2); // This will not work. callbacks.fire("GFG_2"); // This will not work. el_down.innerHTML = res; } </script> </body> </html> Output: Comment More infoAdvertise with us P PranchalKatiyar Follow Improve Article Tags : JQuery jQuery-Methods Similar Reads jQuery Tutorial jQuery is a lightweight JavaScript library that simplifies the HTML DOM manipulating, event handling, and creating dynamic web experiences. The main purpose of jQuery is to simplify the usage of JavaScript on websites. jQuery achieves this by providing concise, single-line methods for complex JavaSc 8 min read What is Ajax ? Imagine browsing a website and being able to submit a form, load new content, or update information without having to refresh the entire page. That's the magic of AJAX. Asynchronous JavaScript and XML (AJAX) is a web development technique that allows web pages to communicate with a web server asynch 5 min read JQuery Set the Value of an Input Text Field Set the value of an input text field in jQuery is useful while working with forms. It is used to add new value to the input text field. In jQuery, there are various methods to set the value of input text fields, these are - val(), prop(), and attr(). These method offers unique capabilities for setti 3 min read How to change Selected Value of a Drop-Down List using jQuery? We will change the default selected value of the dropdown using jQuery. In an HTML select tag, the default selected value is the value given to the first option tag. With jQuery, it is easy to change the selected value from a drop-down list. Below are the methods to change the selected value of a dr 3 min read Form Validation using jQuery Form validation is a process of confirming the relevant information entered by the user in the input field. In this article, we will be validating a simple form that consists of a username, password, and a confirmed password using jQuery.Below are the approaches for validation of form using jQuery:T 5 min read jQuery Introduction jQuery is an open-source JavaScript library that simplifies the interactions between an HTML/CSS document, or more precisely the Document Object Model (DOM). jQuery simplifies HTML document traversing and manipulation, browser event handling, DOM animations, Ajax interactions, and cross-browser Java 7 min read jQuery UI Date Picker A date-picker of jQuery UI is used to provide a calendar to the user to select the date from a Calendar. This date picker is usually connected to a text box so user selection of date from the calendar can be transferred to the textbox. You need to add the below CDN to your HTML document to use it. C 3 min read jQuery ajax() Method The jQuery ajax() method is used to perform asynchronous HTTP requests, allowing you to load data from a server without reloading the webpage. It provides a flexible way to interact with remote servers using GET, POST, or other HTTP methods, supporting various data formats.Syntax:$.ajax({name:value, 4 min read jQuery Cheat Sheet â A Basic Guide to jQuery What is jQuery?jQuery is an open-source, feature-rich JavaScript library, designed to simplify the HTML document traversal and manipulation, event handling, animation, and Ajax with an easy-to-use API that supports the multiple browsers. It makes the easy interaction between the HTML & CSS docum 15+ min read How to Reset an <input type="file"> in JavaScript or jQuery Sometimes, you may want to clear a file that has been selected by the user in an <input type="file"> field, without having to reload the entire page. This can be useful if the user wants to reselect a file or if you need to reset a form.There are two main ways to reset a file input in JavaScri 2 min read Like