w3resource

jQuery: Remove a single callback or a set of callbacks from a callback list

jQuery Fundamental - II : Exercise-52

Remove a single callback or a set of callbacks from a callback list.

Sample solution :

HTML Code :

<!DOCTYPE html>
  <html>
  <head>
  <script src="https://code.jquery.com/jquery-git.js"></script>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Remove a single callback or a set of  callbacks from a callback list.</title>
  </head>
  <body>
</body>
</html>

JavaScript Code :

// A sample function f1 
var foo = function( value ) {
  console.log( "foo: " + value );
};
 
var callbacks = $.Callbacks();
 
// Add f1 to the callback list
callbacks.add( foo );
 
// Fire the items on the list, passing an argument
callbacks.fire( "JavaScript" );
 
// Lock the callbacks list
callbacks.lock();
 
// Test the lock-state of the list
console.log ( callbacks.locked() );
// true

See the Pen jquery-fundamental-exercise-52 by w3resource (@w3resource) on CodePen.


Contribute your code and comments through Disqus.

Previous: Check the lock-state of a callback list.
Next: Attaches a change event to the select element (Use to create a drop-down list.) that gets the text for each selected option and writes them in a paragraph.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/jquery-exercises/2/jquery-fundamental-exercise-52.php