js 回调 callback

<html>
<head>
<title>按钮点击事件示例</title>
<script>
function a(callback) {      
   console.log("执行函数a!");   
   console.log("调用回调函数");   
   callback(); // 调用回调函数
}

function b(){ console.log("回调函数b"); }   

function c() { console.log("回调函数c"); }   
  
function execute(){ a(b); a(c); }

<!-- execute(); -->
</script>
</head>
<body>
<button onclick = "execute()">回调函数</button>
</body>
<html>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章