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



filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


Output:

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

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


Output:




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.