欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery學(xué)習(xí)筆記之jQuery動(dòng)畫效果

 更新時(shí)間:2013年09月09日 16:56:06   作者:  
本次學(xué)習(xí)分為兩個(gè)文件的測(cè)試,第一個(gè)是基本動(dòng)畫,第二個(gè)是滑動(dòng)和透明動(dòng)畫效果,分別如下

基本動(dòng)畫代碼:

復(fù)制代碼 代碼如下:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Hello World jQuery!</title>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>

<script type="text/javascript">
$(document).ready(function()
{

//基本的動(dòng)畫函數(shù)主要分為show, hide和toggle三個(gè). 都提供了無參數(shù)的版本
//并且都提供了兩個(gè)參數(shù)的重載,如show( speed, [callback] ),
//callback,簽名如下:function callback() {this;}在回調(diào)函數(shù)中的this 是執(zhí)行此函數(shù)的DOM 對(duì)象. 會(huì)在動(dòng)畫結(jié)束時(shí)執(zhí)行.
//因?yàn)榛卣{(diào)函數(shù)可以省略, 所以可以傳入一個(gè)數(shù)值作為唯一參數(shù), 則會(huì)在參數(shù)規(guī)定的時(shí)間內(nèi)用動(dòng)畫效果的顯示/隱藏元素
//參數(shù)可以使用三種預(yù)定速度之一的字符串("slow", "normal", "fast")
//或直接使用數(shù)字表示動(dòng)畫時(shí)長(zhǎng),單位是毫秒數(shù)值(如500).


//動(dòng)畫速度
var speed = 500;
//綁定事件處理
$("#btnShow").click(function(event)
{
//取消事件冒泡
event.stopPropagation();
//設(shè)置彈出層位置
var offset = $(event.target).offset();
$("#divPop").css({ top: offset.top + $(event.target).height()+ "px", left: offset.left });
//動(dòng)畫顯示
$("#divPop").show(speed);
});
//單擊空白區(qū)域隱藏彈出層
$(document).click(function(event) { $("#divPop").hide(speed) });
//單擊彈出層則自身隱藏
$("#divPop").click(function(event) {
event.stopPropagation()
$("#divPop").hide(speed);
});


var flip = 0;
$("#btnP").click(function () {
$("p").toggle("fast");
//$("p").toggle( flip++ % 2 == 0 );
});


//綁定事件處理
$("#btnT").click(function(event)
{
//取消事件冒泡
event.stopPropagation();
//設(shè)置彈出層位置
var offset = $(event.target).offset();
$("#divPop").css({ top: offset.top + $(event.target).height() + "px", left: offset.left });
//切換彈出層的顯示狀態(tài)
$("#divPop").toggle(speed);
});

});
</script>

</head>
<body>
<div>
<br /><br /><br />
<button id="btnShow">顯示提示文字</button>
<button id=btnP>顯示段落</button>
<button id=btnT>toggle函數(shù)測(cè)試</button>
</div>
<!-- 彈出層-->
<div id="divPop" style="background-color: #f0f0f0; border: solid 1px
#000000; position: absolute; display:none;
width: 600px; height: 100px;">
<div style="text-align: center;">彈出層</div>
</div>
<p>這個(gè)是一個(gè)段落</p>
<p>這個(gè)是第二個(gè)段落</p>
</body>
</html>


============================================================

滑動(dòng)動(dòng)畫和透明動(dòng)畫效果代碼:

復(fù)制代碼 代碼如下:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Hello World jQuery!</title>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>

<script type="text/javascript">
$(document).ready(function()
{

//滑動(dòng)動(dòng)畫效果
$("#btnShow").click(function(){
$("#divPop").slideDown("fast");
});

$("#btnHide").click(function(){
$("#divPop").slideUp("slow");
});

$("#btnT").click(function(){
$("#divPop").slideToggle("slow");
});


//透明度動(dòng)畫效果

$("#bShow").click(function(){
$("#divPop").fadeIn(2000);
});

$("#bHide").click(function(){
$("#divPop").fadeOut("slow");
});

//指定到透明度
$("#bHelf").click(function(){
$("#divPop").fadeTo("slow",0.3);
});

 

});
</script>

</head>
<body>
<div>
<br /><br /><br />
<button id="btnShow">顯示提示文字</button>
<button id="btnHide">隱藏提示文字</button>
<button id=btnT>toggle函數(shù)測(cè)試</button>
<br />
<button id=bShow>淡入</button>
<button id=bHide>淡出</button>
<button id=bHelf>半透明</button>
</div>
<!-- 彈出層-->
<div id="divPop" style="background-color: #f0f0f0; border: solid 1px
#000000; position: absolute; display:none;
width: 600px; height: 100px;">
<div style="text-align: center;">彈出層</div>
</div>
<p>這個(gè)是一個(gè)段落</p>
<p>這個(gè)是第二個(gè)段落</p>
</body>
</html>

相關(guān)文章

最新評(píng)論