Skip to content
Related Articles

Related Articles

Improve Article
jQuery callbacks.fired() Method
  • Last Updated : 10 Jul, 2020

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 returns true because the fire() method has been called at least once.






<!DOCTYPE HTML>
<html>
  
<head>
    <script src=
    </script>
</head>
  
<body style="text-align:center;">
    <h1 style="color:green;">
        GeeksForGeeks
    </h1>
  
    <p>
        JQuery | callbacks.fired() method
    </p>
  
    <button onclick="Geeks();">
        click here
    </button>
      
    <p id="GFG_DOWN"></p>
  
    <script>
        var el_down = document.getElementById("GFG_DOWN");
        var res = "";
        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>";
            };
  
            // Adding the function 1
            callbacks.add(fun1);
              
            // Calling with "GFG_1"
            callbacks.fire("GFG_1");
              
            // Calling callbacks.fired()
            // method to get true
            el_down.innerHTML = callbacks.fired();
        
    </script>
</body>
  
</html>

Output:

Example 2: This example returns false because the fire() method hasn’t been called.




<!DOCTYPE HTML>
<html>
  
<head>
    <script src=
    </script>
</head>
  
<body style="text-align:center;">
    <h1 style="color:green;">
        GeeksForGeeks
    </h1>
  
    <p>
        JQuery | callbacks.fired() method
    </p>
  
    <button onclick="Geeks();">
        click here
    </button>
      
    <p id="GFG_DOWN"></p>
  
    <script>
        var el_down = document.getElementById("GFG_DOWN");
        var res = "";
        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>";
            };
  
            // Adding the function 1
            callbacks.add(fun1);
              
            // Adding again
            callbacks.add(fun1);
              
            // Calling callbacks.fired() but 
            // This time we will get false
            el_down.innerHTML = callbacks.fired();
        
    </script>
</body>
  
</html>

Output:




My Personal Notes arrow_drop_up
Recommended Articles
Page :