Open In App

jQuery callbacks.disabled() Method

Last Updated : 07 Jul, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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=
    </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.disabled() method";
  
        var result = "";
        var callbacks = jQuery.Callbacks();
  
        function Geeks() {
          
            // 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=
    </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.disabled() method";
        var result = "";
        var callbacks = jQuery.Callbacks();
        function disable() {
            callbacks.disable();
        }
        function Geeks() {
  
            // 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:



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads