jQuery 回調(diào)函數(shù)(callback)的使用和基礎(chǔ)
還是先貼代碼吧
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="js/jquery.js"></script>
</head>
<style>
body{font-family: "微軟雅黑";width: 980px; margin: 0 auto; text-align: center;}
.box{
width: 300px;
height: 300px;
background: green;
border: 1px solid #e6e6e6;
margintop: 50px;
line-height: 200px;
position: absolute;
}
button{
border: none;
background: green;
width: 100px;
height: 50px;
line-height: 50px;
color: #fff;
font-size: 16px;
margin-top: 50px;
}
</style>
<body>
<button>點(diǎn)擊開(kāi)始動(dòng)畫(huà)</button>
<div class="box" ></div>
<script>
$(document).ready(function(){
$("button").click(function(){
var div=$(".box");
div.animate({height:'200px',opacity:'0.4'},"slow");
div.animate({width:'200px',opacity:'0.8'},"slow");
div.animate({height:'100px',opacity:'0.4'},"slow");
div.animate({width:'100px',opacity:'0.8'},"slow");
div.animate({right:'100px',opacity:'0.8'},"slow");
div.animate({bottom:'100px',opacity:'0.8'},"slow");
div.animate({left:'100px',opacity:'0.8'},"slow");
div.animate({top:'100px',opacity:'0.8'},"slow",function(){
alert("The paragraph is over");
});
});
});
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
var div=$(".box");
div.animate({height:'300px',opacity:'0.4'},"slow");
div.animate({width:'300px',opacity:'0.8'},"slow");
div.animate({height:'100px',opacity:'0.4'},"slow");
div.animate({width:'100px',opacity:'0.8'},"slow",function(){
alert("The paragraph is over");
});
});
});
});
</script>
</body>
</html>
所謂的回調(diào)函數(shù),其實(shí)就是在 speed 或 duration 參數(shù)可以設(shè)置許多不同的值,比如 "slow", "fast", "normal" 或毫秒 后面再添加函數(shù),顯示相對(duì)應(yīng)的內(nèi)容,以提示網(wǎng)民
小伙伴們對(duì)jQuery回調(diào)函數(shù)是否有了新的認(rèn)識(shí)了呢,希望本文能給大家一些幫助。
- jquery自定義函數(shù)的多種方法
- jQuery 自定義函數(shù)寫(xiě)法分享
- jQuery回調(diào)函數(shù)的定義及用法實(shí)例
- jQuery.extend 函數(shù)詳解
- jQuery中將函數(shù)賦值給變量的調(diào)用方法
- jquery封裝插件時(shí)匿名函數(shù)形參和實(shí)參的寫(xiě)法解釋
- jQuery下擴(kuò)展插件和拓展函數(shù)的寫(xiě)法(匿名函數(shù)使用的典型例子)
- jQuery構(gòu)造函數(shù)init參數(shù)分析
- jQuery實(shí)用函數(shù)用法總結(jié)
- jQuery 函數(shù)實(shí)例分析【函數(shù)聲明、函數(shù)表達(dá)式、匿名函數(shù)等】
相關(guān)文章
jQuery實(shí)現(xiàn)刪除li節(jié)點(diǎn)的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)刪除li節(jié)點(diǎn)的方法的相關(guān)資料,需要的朋友可以參考下2016-12-12
jQuery判斷網(wǎng)頁(yè)是否已經(jīng)滾動(dòng)到瀏覽器底部的實(shí)現(xiàn)方法
最近做項(xiàng)目遇到這樣的需求,要求基于jq判斷網(wǎng)頁(yè)是否已經(jīng)滾動(dòng)到瀏覽器底部了,下面小編給大家分享實(shí)例代碼,需要的朋友參考下吧2017-10-10
jquery實(shí)現(xiàn)員工信息添加與刪除功能
這篇文章主要為大家詳細(xì)介紹了利用jquery制作簡(jiǎn)易的員工信息添加與刪除,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-09-09
詳解強(qiáng)大的jQuery選擇器之基本選擇器、層次選擇器
自從接觸了jQuery后就為其強(qiáng)大的選擇器所震撼,這也正是jQuery的優(yōu)勢(shì)所在2012-02-02
jQuery 2.0.3 源碼分析之core(一)整體架構(gòu)
這篇文章主要介紹了jQuery 2.0.3 源碼分析之core(一)整體架構(gòu),需要的朋友可以參考下2014-05-05

