jQuery callbacks.disabled() Method
The jQuery callbacks.disabled() method is used to check if the callback is disabled or not. This method returns “true” or “false” depending on the callback.
Syntax:
callbacks.disabled()
Return Value: This method returns a boolean value.
Example 1: This example disables the callback and then call the callbacks.disabled() method to see the result.
<!DOCTYPE HTML> < html > < head > < title > jQuery callbacks.disabled() method </ title > < script src = "https://code.jquery.com/jquery-3.5.0.js" > </ script > </ head > < body style = "text-align:center;" > < h1 style = "color:green;" > w3wiki </ h1 > < p id = "GFG_UP" ></ p > < button onclick = "Beginner();" > 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.disabled() method"; var result = ""; var callbacks = jQuery.Callbacks(); function Beginner() { // First function to be added to the list var fun1 = function (val) { result = result + "This is function 1 and" + " value passed is " + val + "< br >"; }; callbacks.add(fun1); // Adding the function 1 callbacks.fire("GFG_1"); // Calling the function 1 callbacks.disable(); el_down.innerHTML = callbacks.disabled(); } </ script > </ body > </ html > |
Output:
Example 2: This example provides a button to disable the callbacks and check then.
<!DOCTYPE HTML> < html > < head > < title > jQuery callbacks.disabled() method </ title > < script src = "https://code.jquery.com/jquery-3.5.0.js" > </ script > </ head > < body style = "text-align:center;" > < h1 style = "color:green;" > w3wiki </ h1 > < p id = "GFG_UP" ></ p > < button onclick = "Beginner();" > 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.disabled() method"; var result = ""; var callbacks = jQuery.Callbacks(); function disable() { callbacks.disable(); } function Beginner() { // First function to be added to the list var fun1 = function (val) { result = result + "This is function 1 and" + " value passed is " + val + "< br >"; }; callbacks.add(fun1); // Adding the function 1 callbacks.fire("GFG_1"); // Calling the function 1 el_down.innerHTML = callbacks.disabled(); } </ script > </ body > </ html > |
Output:
Contact Us