码迷,mamicode.com
首页 > Web开发 > 详细

没办法,还是要补一下js,回调函数(转载)

时间:2016-05-17 09:44:22      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:

    1. <html> 
    2.  
    3. <head> 
    4.  
    5. <title>回调函数(callback)</title> 
    6. <script language="javascript" type="text/javascript"> 
    7. function a(callback) 
    8. {    
    9.     alert("我是parent函数a!"); 
    10.     alert("调用回调函数"); 
    11.     callback(); 
    12. } 
    13. function b(){ 
    14. alert("我是回调函数b"); 
    15.  
    16. } 
    17. function c(){ 
    18. alert("我是回调函数c"); 
    19.  
    20. } 
    21.  
    22. function test() 
    23. { 
    24.     a(b); 
    25.    a(c); 
    26. } 
    27.  
    28. </script> 
    29. </head> 
    30.  
    31. <body> 
    32. <h1>学习js回调函数</h1> 
    33. <button onClick=test()>click me</button> 
    34. <p>应该能看到调用了两个回调函数</p> 
    35. </body> 
    36.  
    37. </html>

没办法,还是要补一下js,回调函数(转载)

标签:

原文地址:http://www.cnblogs.com/sss-justdDoIt/p/5500306.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!