Callback 函数在当前动画 100% 完成之后执行。 隐藏与显示.gif

  1. <html>
  2. <head>
  3. <script type="text/javascript" src="/jquery/jquery.js"></script>
  4. <script type="text/javascript">
  5. $(document).ready(function(){
  6. $("button").click(function(){
  7. $("p").hide(1000,function(){
  8. alert("The paragraph is now hidden");
  9. });
  10. });
  11. });
  12. </script>
  13. </head>
  14. <body>
  15. <button type="button">Hide</button>
  16. <p>This is a paragraph with little content.</p>
  17. </body>
  18. </html>

正确(有callback)

  1. $("p").hide(1000,function(){
  2. alert("The paragraph is now hidden");
  3. });

错误(没有callback)

  1. $("p").hide(1000);
  2. alert("The paragraph is now hidden");