jQuery UI API - .hide()
所屬類別
特效(Effects) | 特效核心(Effects Core) | 方法重載(Method Overrides) | 方法(Methods)
用法
描述:使用自定義效果來隱藏匹配的元素。
返回:jQuery
.hide( effect [, options ] [, duration ] [, complete ] )
| 參數 | 類型 | 描述 | 默認值 |
|---|---|---|---|
| effect | String | 一個字串,指示要使用哪一種特效。 | |
| options | Object | 特效具體的設置和 easing。 | |
| duration | Number 或 String | 一個字串或一個數字,指定動畫將運行多久。 | 400 |
| complete | Function() | 一旦動畫完成時要調用的函數。 |
.hide( options )
| 參數 | 類型 | 描述 |
|---|---|---|
| options | Object | 所有的動畫設置。唯一一個必需的屬性是 effect。
|
該插件擴展自 jQuery 內置的 .hide() 方法。如果 jQuery UI 未加載,調用 .hide() 方法不會直接失敗,因為該方法在 jQuery 中存在。但是不會發生預期的行為。
實例
使用降落特效(Drop Effect)隱藏一個 div。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>.hide() 演示</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<style>
div {
width: 100px;
height: 100px;
background: #ccc;
border: 1px solid #000;
}
</style>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
</head>
<body>
<button>隱藏 div</button>
<div></div>
<script>
$( "button" ).click(function() {
$( "div" ).hide( "drop", { direction: "down" }, "slow" );
});
</script>
</body>
</html>
