js回调函数写法_JS回调函数简单用法示例

时间:2021-06-16  来源:php函数  阅读:
 代码如下

  testCallBack.html

  <script type="text/javascript">

   functiona(callback){

    console.log("这里是a函数!可以执行a函数的业务逻辑。");

    if(callback){

      console.log("进入if callback!");

      returncallback(1,2,3);//可以返回回调函数的返回值  也可以在调用回调函数时设置回调函数的参数

    }else{

      console.log("还没有 进入if callback!");

    }

  }

  functionb(m,n,k){

    console.log("测试::第一个参数"+m+" 第二个参数:"+n+" 第三个参数:"+k);

    return0;

  }

  vartestBt = document.getElementById("bt_test");

  testBt.onclick=function(){console.log(a(b));};

  </script>

运行效果图如下:

js回调函数写法_JS回调函数简单用法示例

http://m.bbyears.com/jiaocheng/124165.html

推荐访问:jsonp回调函数
相关阅读 猜你喜欢
本类排行 本类最新