jQuery: Call all of the callbacks with the given arguments
jQuery Fundamental - I : Exercise-46
Call all of the callbacks with the given arguments.
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>Call all of the callbacks with the given arguments.</title>
</head>
<body>
</body>
</html>
JavaScript Code :
// Sample function (f1) to be added to a callbacks list
var f1 = function( value ) {
console.log( "f1:" + value );
};
var callbacks = $.Callbacks();
// Add the function f1 to the list
callbacks.add( f1 );
// Fire the items on the list
callbacks.fire( "JavaScript" );
callbacks.fire( "jQuery" );
See the Pen jquery-fundamental-exercise-46 by w3resource (@w3resource) on CodePen.
Contribute your code and comments through Disqus.
Previous: Using jQuery remove all of the callbacks from a list.
Next: Using jQuery check if the callbacks have already been called at least once.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook