色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

jQuery 動(dòng)畫基礎(chǔ)教程

注意此代碼需要用到j(luò)query的js文件,才可以用所以大家可以先下載一個(gè)jquery文件,注意調(diào)用路徑。
代碼:
復(fù)制代碼 代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>jQuery動(dòng)畫基礎(chǔ)</title>
<script type="text/Javascript" src="../js/jquery-1.2.6.js"></script>
<style type="text/css">
.theImage{
position:relative;
background:Green;
width:100px;
}
</style>
<script type="text/Javascript">
$(function(){
$("#btnShow").click(function(){
//$("#block").show(1000);//沒有參數(shù)則沒有動(dòng)畫效果
//$("#block").fadeIn("slow");//根據(jù)透明度顯示或隱藏
$("#block").slideDown();//拉下來。只改變高度
});
$("#btnHide").click(function(){
//$("#block").hide("normal");//slow,normal,fast
//$("#block").fadeOut(5000);
$("#block").slideUp();
});

//自定義動(dòng)畫
$("#btnImage").click(function(){
$("#imageDiv").animate(
//I
//移動(dòng)到的位置,這里的位置是相對(duì)與原來的位置
//top即相對(duì)原來的位置向上移動(dòng)多少距離,沒搞明白,結(jié)果是向下移動(dòng)了。
//{left:"400px",top:"100px"},
//3000
//II
{left:"+=50",width:"300px",height:"200px"},//改變位置的同時(shí)改變寬度高度
3000
);
});
//同時(shí)執(zhí)行兩個(gè)動(dòng)畫,執(zhí)行完一個(gè),然后接著執(zhí)行另一個(gè)。
$("#btnImage").click(function(){
$("#imageDiv").animate(
{left:"100px",width:"30px",height:"20px"},
3000,
function(){alert('callback函數(shù)');}//動(dòng)畫結(jié)束后要執(zhí)行的函數(shù)
);
});
});
</script>
</head>
<body>
<div>
<button id="btnShow"> Show</button>
<button id="btnHide">Hide</button>
<div id="block" style="background:#369; width:150px; height:100px; ">Hello!</div>
<button id="btnImage">moveImage</button>
<div id="imageDiv" class="theImage">image</div>
<div>hi</div>
</div>
</body>
</html>

JavaScript技術(shù)jQuery 動(dòng)畫基礎(chǔ)教程,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 靖宇县| 醴陵市| 北流市| 通化市| 清涧县| 西华县| 厦门市| 天长市| 霍山县| 镇宁| 炉霍县| 神池县| 平远县| 七台河市| 宝山区| 常熟市| 英山县| 融水| 永定县| 石城县| 遵义市| 定日县| 青川县| 盐津县| 临沭县| 乐清市| 江孜县| 翁源县| 改则县| 平南县| 神池县| 宜丰县| 秦安县| 巴南区| 衡水市| 望奎县| 互助| 成安县| 韩城市| 琼结县| 邵阳县|