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

jQuery實現(xiàn)基本淡入淡出效果的方法詳解

 更新時間:2018年09月05日 11:21:19   作者:furway  
這篇文章主要介紹了jQuery實現(xiàn)基本淡入淡出效果的方法,結合實例形式詳細分析了jQuery使用fadeIn()、fadeOut()及fadeToggle()等方法控制頁面元素淡入淡出顯示效果的相關操作技巧,需要的朋友可以參考下

本文實例講述了jQuery實現(xiàn)基本淡入淡出效果的方法。分享給大家供大家參考,具體如下:

jQuery fadeIn()方法:用于淡入已隱藏的元素

jQuery fadeOut()方法:用于淡出可見的元素

<!DOCTYPE html>
<html>
<head>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").fadeIn();
});
});
</script>
</head>
<body>
<p>演示帶有不同參數(shù)的fadeIn()方法。</p>
<button>點擊</button>
<br />
<div id="div1" style="width:80px;height:80px;display:none;background-color:red;"></div>
</body>
</html>

運行結果:

jQuery fadeToggle()方法:方法可以在fadeIn()與fadeOut()方法之間進行切換

語法:$(selector).fadeToggle(speed,callback);

如果元素已淡出,則fadeToggle()會向元素添加淡入效果

如果元素已淡入,則fadeToggle()會向元素添加淡出效果

<!DOCTYPE html>
<html>
<head>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").fadeToggle();
});
});
</script>
</head>
<body>
<button>點擊</button>
<br/>
<div id="div1" style="width:80px;height:80px;background-color:red;"</div>
</body>
</html>

運行結果:

jQuery fadeTo()方法:允許漸變?yōu)榻o定的不透明(值介于0與1之間)

語法:$(selector).fadeTo(speed,opacity,callback);

<!DOCTYPE html>
<html>
<head>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").fadeTo(1000,0.2);
});
});
</script>
</head>
<body>
<button>點擊</button>
<br/>
<div id="div1" style="width:80px;height:80px;background-color:red;"</div>
</body>
</html>

運行結果:

感興趣的朋友可以使用在線HTML/CSS/JavaScript代碼運行工具http://tools.jb51.net/code/HtmlJsRun測試上述代碼運行效果。

更多關于jQuery相關內容還可查看本站專題:《jQuery切換特效與技巧總結》、《jQuery擴展技巧總結》、《jQuery常用插件及用法總結》、《jQuery拖拽特效與技巧總結》、《jQuery表格(table)操作技巧匯總》、《jQuery常見經典特效匯總》、《jQuery動畫與特效用法總結》及《jquery選擇器用法總結

希望本文所述對大家jQuery程序設計有所幫助。

相關文章

最新評論