Javascript 回调函数jQuery
执行Javascript 回调函数jQuery,javascript,jquery,Javascript,Jquery,执行dragTrack()函数后,需要运行helloWorld()。但是在dragTrack之后没有调用helloWorld dragTrack(function(){ helloWorld(); }); function dragTrack() { alert('first'); } function helloWorld() { alert('second'); } 您正在将函数作为参数传递,但需要更改dragTrack以接受回调并调用它 dragTrack(
dragTrack()
函数后,需要运行helloWorld()
。但是在dragTrack
之后没有调用helloWorld
dragTrack(function(){
helloWorld();
});
function dragTrack() {
alert('first');
}
function helloWorld() {
alert('second');
}
您正在将函数作为参数传递,但需要更改
dragTrack
以接受回调并调用它
dragTrack(helloWorld);
函数dragTrack(回调){
警报(“第一”);
如果(回调){
回调();
}
}
函数helloWorld(){
警报(“第二”);
}
您正在dragTrack()调用中将helloWorld()作为参数传递,但您没有处理它。dragTrack函数需要一个回调参数,因此可以使用helloWorld()函数作为参数。dragTrack不接受任何参数?您应该首先研究,然后提问,,,参考这些答案