Problems with jQuery animations
Many jQuery functions involve animation. These functions may take speed or duration as optional parameters.
例子:$("p").hide("slow")
The speed or duration parameter can be set to many different values, such as "slow", "fast", "normal" or milliseconds.
example
The following examples call back the function after the hiding effect is fully realized:
use callback
<script> $(document).ready(function(){ $("button").click(function(){ $("p").hide("slow",function(){ alert("Paragraph is now hidden"); }); }); }); </script> </head> <body> <button>隐藏</button> <p>Our paragraph content, click the "Hide" button and I will disappear</p>
The following examples have no callback function, and the alert box will pop up before the hiding effect is completed:
<script> $(document).ready(function(){ $("button").click(function(){ $("p").hide(1000); alert("The paragraph is now hidden"); }); }); </script> </head> <body> <button>隐藏</button> <p>This is a paragraph with very little content</p>