two parameters. The first parameter is the function called after the second parameter represents the number of milliseconds. Listing 15 shows a way to complete this operation.
Listing 15. Calling a group of functions in the callback
window.setTimeout(function(){alert(‘First!');alert(‘Second!');}, 5000);
Listing 16 shows a better way to complete this operation.
Listing 16. A better way to call a series of functions
Function.proto
is the function called after the second parameter represents the number of milliseconds. Listing 15 shows a way to complete this operation.
Listing 15. Calling a group of functions in the callback
window.setTimeout(function(){alert(‘First!');alert(‘Second!');}, 5000);
Listing 16 shows a better way to complete this operation.
Listing 16. A better way to call a series of functions
Function.prototype.sequence=function(g) { var f=this; re
operation.Listing 16. A better way to call a series of functions
Function.prototype.sequence=function(g) { var f=this; return function() { f();g(); }};function alertFrst() { alert(‘First!'); }function alertSec() { alert(‘Second!'); }setTimeout( alertFrst.sequence(alertSec), 5000);
When processing an event, if you want to call another callback after calling a callback, you can a
dynamic HTML by using program code array. prototype. fold = function (templatefn) {var Len = This. length; var STR = ''; For (VAR I = 0; I alertsec () {alert ('second! ');} SetTimeout (alertfrst. sequence (alertsec), 5000); when processing an event, if you want to call another callback after calling a callback, you can also use the code extension in listing 16. This may be an exercise that you need to complete on your own. Now your interest is
. Calling a group of functions in the callbackWindow. setTimeout (function () {alert ('first! '); Alert ('second! ');}, 5000 );Listing 16 shows a better way to complete this operation.Listing 16. A better way to call a series of functionsFunction. prototype. sequence = function (g ){Var f = this;Return function (){F (); g ();}};Function alertFrst () {alert ('first! ');}Function alertSec () {alert ('second! ');}SetTimeout (alertFrst. sequence (
(' first! '); Alert (' second! ');}, 5000);Listing 16 shows a better way to do this.Listing 16. A better way to call a series functionFunction.prototype.sequence=function (g) {var f=this;return function () {f (); G ();}};function Alertfrst () {alert (' first! ');}function Alertsec () {alert (' second! ');}SetTimeout (Alertfrst.sequence (alertsec), 5000);You can also use the code extension in Listing 16 if
use a set of functions as a callback function. For this to happen, the Window.settimeout function is used, which has two parameters. The first parameter is the function that is called after the number of milliseconds represented by the second parameter. Listing 15 shows one way to do this.
Listing 15. Calling a set of functions in a callback
Window.settimeout (function () {alert (' first! '); Alert (' second! ');}, 5000);
Listing 16 shows a better way to do this.
Listing 16. A better way
() {alert (' first! '); Alert (' second! ');}, 5000);
Listing 16 shows a better way to do this.
listing 16. A better way to invoke a series function
Function.prototype.sequence=function (g) {
var f=this;
return function () {
f (); G ();
}
};
function Alertfrst () {alert (' first! ');}
function Alertsec () {alert (' second! ');}
SetTimeout (Alertfrst.sequence (
Contact Us
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.