Jquery Fade用法詳解
jquery淡入淡出演示
感覺用法都差不多,目前看來還比較簡(jiǎn)單。
fadeIn
fadeOut
fadeToggle
fadeTo
一共4種用法
CSS代碼
<style>
div{background-color:#eaeaea;border:solid 1px #999999;width:100px;height:100px;text-align:center;line-height:100px;font-size:16px;display:none;margin:10px;}
</style>
JS代碼
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#one").click(function(){
$("#con_a").fadeIn(100);
$("#con_b").fadeIn(500);
$("#con_c").fadeIn(1000);
});
$("#two").click(function(){
$("#con_a").fadeOut(100);
$("#con_b").fadeOut(500);
$("#con_c").fadeOut(1000);
});
$("#three").click(function(){
$("#con_a").fadeToggle(100);
$("#con_b").fadeToggle(500);
$("#con_c").fadeToggle(1000);
});
$("#four").click(function(){
$("#con_a").fadeTo("slow",0.5);
$("#con_b").fadeTo("slow",0.7);
$("#con_c").fadeTo("slow",0.9);
});
});
</script>
HTML代碼
<!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" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Jquery Fade demo</title>
<style>
div{background-color:#eaeaea;border:solid 1px #999999;width:100px;height:100px;text-align:center;line-height:100px;font-size:16px;display:none;margin:10px;}
</style>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#one").click(function(){
$("#con_a").fadeIn(100);
$("#con_b").fadeIn(500);
$("#con_c").fadeIn(1000);
});
$("#two").click(function(){
$("#con_a").fadeOut(100);
$("#con_b").fadeOut(500);
$("#con_c").fadeOut(1000);
});
$("#three").click(function(){
$("#con_a").fadeToggle(100);
$("#con_b").fadeToggle(500);
$("#con_c").fadeToggle(1000);
});
$("#four").click(function(){
$("#con_a").fadeTo("slow",0.5);
$("#con_b").fadeTo("slow",0.7);
$("#con_c").fadeTo("slow",0.9);
});
});
</script>
</head>
<body>
<h1>Jquery淡入淡出演示</h1>
<button id="one">點(diǎn)擊我淡入</button>
<button id="two">點(diǎn)擊我淡出</button>
<button id="three">點(diǎn)擊我切換淡入淡出</button>
<button id="four">透明度</button>
<div id="con_a">1</div>
<div id="con_b">2</div>
<div id="con_c">3</div>
</body>
</html>
效果圖

到此這篇關(guān)于Jquery Fade用法詳解的文章就介紹到這了,更多相關(guān)Jquery Fade用法內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
jquery ajax 如何向jsp提交表單數(shù)據(jù)
ajax技術(shù)在做表單數(shù)據(jù)傳值非常棒,給用戶帶來很好的用戶體驗(yàn)度,同時(shí),使用jquery可以簡(jiǎn)化開發(fā),提高效率。下面給大家介紹jquery ajax 如何向jsp提交表單數(shù)據(jù),需要的朋友可以參考下2015-08-08
基于Jquery的回車成tab焦點(diǎn)切換效果代碼(Enter To Tab )
基于Jquery的回車成tab焦點(diǎn)切換效果代碼(Enter To Tab ),需要的朋友可以參考下。2010-11-11
Jquery仿IGoogle實(shí)現(xiàn)可拖動(dòng)窗口示例代碼
這個(gè)拖動(dòng)窗口是根據(jù)一個(gè)Jquery的框架直接做出來的:easywidgets,廢話就不多說了,直接把源代碼貼出來,讓大家學(xué)習(xí)2014-08-08
jQuery使用post方法提交數(shù)據(jù)實(shí)例
這篇文章主要介紹了jQuery使用post方法提交數(shù)據(jù),實(shí)例分析了jQuery中post方法的使用技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-03-03
淺談jQuery中對(duì)象遍歷.eq().first().last().slice()方法
本文給大家分析了jQuery中的對(duì)象遍歷.eq().first().last().slice()方法的使用,以及他們之間的區(qū)別,jQuery源碼中的使用。2014-11-11
jQuery與getJson結(jié)合的用法實(shí)例
這篇文章主要介紹了jQuery與getJson結(jié)合的用法,實(shí)例分析了jquery解析json數(shù)據(jù)及數(shù)組遍歷的相關(guān)操作技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-08-08

