亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Manual Rujukan Cina jQuery / jQuery Callback

jQuery Callback

jQuery Callback 方法


Callback 函數(shù)在當(dāng)前動(dòng)畫 100% 完成之后執(zhí)行。


jQuery 動(dòng)畫的問題

許多 jQuery 函數(shù)涉及動(dòng)畫。這些函數(shù)也許會(huì)將 speed 或 duration 作為可選參數(shù)。

例子:$("p").hide("slow")

speed 或 duration 參數(shù)可以設(shè)置許多不同的值,比如 "slow", "fast", "normal" 或毫秒。

以下實(shí)例在隱藏效果完全實(shí)現(xiàn)后回調(diào)函數(shù):

實(shí)例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("p").hide("slow",function(){
      alert("段落現(xiàn)在被隱藏了");
    });
  });
});
</script>
</head>
<body>
<button>隱藏</button>
<p>我們段落內(nèi)容,點(diǎn)擊“隱藏”按鈕我就會(huì)消失</p>
</body>
</html>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例

以下實(shí)例沒有回調(diào)函數(shù),警告框會(huì)在隱藏效果完成前彈出:

實(shí)例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("p").hide(1000);
    alert("現(xiàn)在段落被隱藏了");
  });
});
</script>
</head>
<body>
<button>隱藏</button>
<p>這是一個(gè)段落,內(nèi)容很少</p>
</body>
</html>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例