Home > Web Front-end > JS Tutorial > body text

javascript custom callback function sample code_jquery

WBOY
Release: 2016-05-16 16:35:20
Original
1030 people have browsed it

If you call it directly in function a, then the callback function will be restricted. But using functions as parameters has the following benefits: when you do a(b), function b becomes a callback function, and when you can also do a(c), function c becomes a callback function. If you write functiona(){...;b();}, you lose the flexibility of variables.

Copy code The code is as follows:

function a(index,callback){
callback(index);
}

function b(index){
alert(index);
}

a(10000,b);

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template