W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
jQuery UI隱藏(Hide)通過使用自定義的效果來隱藏匹配的元素。
如需了解更多有關(guān).hide()
方法的細節(jié),請查看API文檔.hide()。
點擊按鈕預覽特效。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI 特效 - .hide() 演示</title>
<link rel="stylesheet" rel="external nofollow" target="_blank" >
<script src="http://code.jquery.com/jquery-1.9.1.js" rel="external nofollow" ></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js" rel="external nofollow" ></script>
<link rel="stylesheet" rel="external nofollow" target="_blank" >
<style>
.toggler { width: 500px; height: 200px; }
#button { padding: .5em 1em; text-decoration: none; }
#effect { width: 240px; height: 135px; padding: 0.4em; position: relative; }
#effect h3 { margin: 0; padding: 0.4em; text-align: center; }
</style>
<script>
$(function() {
// 運行當前選中的特效
function runEffect() {
// 從中獲取特效類型
var selectedEffect = $( "#effectTypes" ).val();
// 大多數(shù)的特效類型默認不需要傳遞選項
var options = {};
// 一些特效帶有必需的參數(shù)
if ( selectedEffect === "scale" ) {
options = { percent: 0 };
} else if ( selectedEffect === "size" ) {
options = { to: { width: 200, height: 60 } };
}
// 運行特效
$( "#effect" ).hide( selectedEffect, options, 1000, callback );
};
// 回調(diào)函數(shù)
function callback() {
setTimeout(function() {
$( "#effect" ).removeAttr( "style" ).hide().fadeIn();
}, 1000 );
};
// 根據(jù)選擇菜單值設置特效
$( "#button" ).click(function() {
runEffect();
return false;
});
});
</script>
</head>
<body>
<div class="toggler">
<div id="effect" class="ui-widget-content ui-corner-all">
<h3 class="ui-widget-header ui-corner-all">隱藏(Hide)</h3>
<p>
Etiam libero neque, luctus a, eleifend nec, semper at, lorem. Sed pede. Nulla lorem metus, adipiscing ut, luctus sed, hendrerit vitae, mi.
</p>
</div>
</div>
<select name="effects" id="effectTypes">
<option value="blind">百葉窗特效(Blind Effect)</option>
<option value="bounce">反彈特效(Bounce Effect)</option>
<option value="clip">剪輯特效(Clip Effect)</option>
<option value="drop">降落特效(Drop Effect)</option>
<option value="explode">爆炸特效(Explode Effect)</option>
<option value="fold">折疊特效(Fold Effect)</option>
<option value="highlight">突出特效(Highlight Effect)</option>
<option value="puff">膨脹特效(Puff Effect)</option>
<option value="pulsate">跳動特效(Pulsate Effect)</option>
<option value="scale">縮放特效(Scale Effect)</option>
<option value="shake">震動特效(Shake Effect)</option>
<option value="size">尺寸特效(Size Effect)</option>
<option value="slide">滑動特效(Slide Effect)</option>
</select>
<a href="#" id="button" class="ui-state-default ui-corner-all">運行特效</a>
</body>
</html>
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: