jQuery動(dòng)畫顯示和隱藏效果實(shí)例演示(附demo源碼下載)
本文實(shí)例講述了jQuery動(dòng)畫顯示和隱藏效果。分享給大家供大家參考,具體如下:
運(yùn)行效果截圖如下:

點(diǎn)擊此處查看在線演示。
完整實(shí)例代碼點(diǎn)擊此處本站下載。
具體代碼如下:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JQuery 動(dòng)畫顯示和隱藏效果</title>
<script>
/*
1.$("頁(yè)面元素類型").show(時(shí)間, 回調(diào)函數(shù));以優(yōu)雅的動(dòng)畫顯示所有匹配的元素,并在顯示完成后可選地觸發(fā)一個(gè)回調(diào)函數(shù);指定時(shí)間后依次執(zhí)行回調(diào)函數(shù),頁(yè)面上能找到幾個(gè),就連著執(zhí)行幾次。時(shí)間可以為毫秒數(shù),也可以是slow,nomal,fast
2.$("頁(yè)面元素").toggle();切換此元素的顯示狀態(tài)。如果它是顯示的,讓它隱藏,如果它是隱藏的,讓它顯示。
3.$("頁(yè)面元素").slideDown(時(shí)間,回調(diào)函數(shù))通過(guò)高度變化(向下增大)來(lái)動(dòng)態(tài)地顯示所有匹配的元素,在顯示完成后可選地觸發(fā)一個(gè)回調(diào)函數(shù)。
4.$("頁(yè)面元素").fadeIn(時(shí)間,回調(diào)函數(shù))通過(guò)不透明度的變化來(lái)實(shí)現(xiàn)所有匹配元素的淡入效果,并在動(dòng)畫完成后可選地觸發(fā)一個(gè)回調(diào)函數(shù)。
*/
</script>
<script language="javascript" src="jquery1.3.2.js" ></script>
<script>
function test_show() {
//$("#myImage").show(2000,function(){alert("演示完畢!");});
$("img").show(2000,function(){alert("演示完畢!");});
}
function test_hide() {
//$("#myImage").hide(2000,function(){alert("演示完畢!");});
$("img").hide(2000,function(){alert("演示完畢!");});
}
function test_slideDown() {
$("#myImage2").slideDown(500,function(){alert("滑動(dòng)向下放大完畢");});
}
function test_slideUp() {
$("#myImage2").slideUp(2000,function(){alert("滑動(dòng)向上縮小完畢");});
}
function test_slideToggle() {
$("#myImage2").slideToggle(1000,function(){alert("切換滑動(dòng)效果完畢");});
}
function test_fadeIn() {
$("#myImage3").fadeIn(2000,function(){alert("淡入完畢");});
}
function test_fadeOut() {
$("#myImage3").fadeOut(2000,function(){alert("淡出完畢");});
}
function test_fadeTo() {
$("#myImage3").fadeTo(2000,0.25,function(){alert("調(diào)整到指定透明度完畢");});
}
</script>
</head>
<body>
<div>
<input type="button" value="顯示" onClick="$('p').show();" />
<input type="button" value="隱藏" onClick="$('p').hide();" />
|||
<input type="button" value="延時(shí)顯示" onClick="test_show()" />
<input type="button" value="延時(shí)隱藏" onClick="test_hide()" />
<input type="button" value="切換元素的可見(jiàn)狀態(tài)" onclick="$('#myImage1').toggle()" />
|||
<input type="button" value="滑動(dòng)向下放大" onClick="test_slideDown()" />
<input type="button" value="滑動(dòng)向上縮小" onClick="test_slideUp()" />
<input type="button" value="切換滑動(dòng)效果" onClick="test_slideToggle()" />
|||
<input type="button" value="淡入" onClick="test_fadeIn()" />
<input type="button" value="淡出" onClick="test_fadeOut()" />
<input type="button" value="調(diào)整到指定透明度" onClick="test_fadeTo()" />
</div>
<p style="display:none">Hello World!</p>
<p style="display:none">Hello World!</p>
<p style="display:none">Hello World!</p>
<p style="display:none">Hello World!</p>
<img id="myImage" src="images/11.jpg" style="display:none" />
<img id="myImage1" src="images/1.jpg" style="display:none" />
<img id="myImage2" src="images/2.jpg" style="display:none" />
<img id="myImage3" src="images/3.jpg" style="display:none" />
</body>
</html>
希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。
- jQuery實(shí)現(xiàn)圖片走馬燈效果的原理分析
- 輕松實(shí)現(xiàn)jquery手風(fēng)琴效果
- jquery淡入淡出效果簡(jiǎn)單實(shí)例
- jQuery實(shí)現(xiàn)的左右移動(dòng)焦點(diǎn)圖效果
- jQuery遮罩層效果實(shí)例分析
- jquery拖拽效果完整實(shí)例(附demo源碼下載)
- jQuery動(dòng)畫效果圖片輪播特效
- php+jQuery+Ajax實(shí)現(xiàn)點(diǎn)贊效果的方法(附源碼下載)
- jQuery實(shí)現(xiàn)的給圖片點(diǎn)贊+1動(dòng)畫效果(附在線演示及demo源碼下載)
- jQuery實(shí)現(xiàn)的點(diǎn)贊隨機(jī)數(shù)字顯示動(dòng)畫效果(附在線演示與demo源碼下載)
- jQuery實(shí)現(xiàn)的指紋掃描效果實(shí)例(附演示與demo源碼下載)
相關(guān)文章
jQuery實(shí)現(xiàn)導(dǎo)航回彈效果
本文主要介紹了jQuery實(shí)現(xiàn)導(dǎo)航回彈效果的實(shí)例,具有很好的參考價(jià)值,下面跟著小編一起來(lái)看下吧2017-02-02
jQuery+css實(shí)現(xiàn)圖片滾動(dòng)效果(附源碼)
圖片滾動(dòng)效果想必大家都已司空見(jiàn)慣了吧,接下來(lái)本文介紹下jQuery+CSS實(shí)現(xiàn)圖片滾動(dòng),感興趣的你可不要錯(cuò)過(guò)了哈,希望可以幫助到你2013-03-03
jQuery 操作option的實(shí)現(xiàn)代碼
js清空option之前清空option ,我的做法是遍歷現(xiàn)有option,將其每個(gè)子元素都置空即可。2011-03-03
jquery實(shí)現(xiàn)LED廣告牌旋轉(zhuǎn)系統(tǒng)圖片切換效果代碼分享
這篇文章主要介紹了jquery實(shí)現(xiàn)LED廣告牌旋轉(zhuǎn)系統(tǒng)圖片切換效果類似路邊場(chǎng)景,很實(shí)用的代碼,推薦給大家,有需要的小伙伴可以參考下。2015-08-08
簡(jiǎn)潔實(shí)用的BootStrap jQuery手風(fēng)琴插件
這篇文章主要介紹了簡(jiǎn)潔實(shí)用的BootStrap jQuery手風(fēng)琴插件知識(shí),非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-08-08
jQuery解析XML與傳統(tǒng)JavaScript方法的差別實(shí)例分析
這篇文章主要介紹了jQuery解析XML與傳統(tǒng)JavaScript方法的差別,實(shí)例分析了jQuery與javascript解析XML文件的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-03-03

