jQuery.effects.define( name [, mode ], effect )
返回:Function
添加的版本:1.12
說明:定義效果。
-
jQuery.effects.define( name [, mode ], effect )
定義與
、 .effect()
、 .show()
和 .hide()
一起使用的新效果。使用 .toggle()
this
作為單個 DOM 元素調用效果方法。 done
參數必須在動畫完成時調用。
jQuery.effects.define()
將新效果存儲在 jQuery.effects.effect[ name ]
中並返回作為 effect
參數提供的函數。
例子:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery.effects.define demo</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
<style>
.elem {
position: absolute;
width: 150px;
height: 150px;
background: #3b679e;
}
</style>
<script src="//code.jquery.com/jquery-1.12.4.js"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
Click anywhere!
<div class="elem"></div>
<script>
$.effects.define( "fade", "toggle", function( options, done ) {
var show = options.mode === "show";
$( this )
.css( "opacity", show ? 0 : 1 )
.animate( {
opacity: show ? 1 : 0
}, {
queue: false,
duration: options.duration,
easing: options.easing,
complete: done
} );
} );
$( document ).on( "click", function() {
$( ".elem" ).toggle( "fade" );
} );
</script>
</body>
</html>
演示:
相關用法
- JQuery jQuery.escapeSelector()用法及代碼示例
- JQuery jQuery.each()用法及代碼示例
- JQuery jQuery.extend()用法及代碼示例
- JQuery jQuery.error()用法及代碼示例
- JQuery jQuery.inArray()用法及代碼示例
- JQuery jQuery.when()用法及代碼示例
- JQuery Mobile jQuery.mobile.path.get()用法及代碼示例
- JQuery jQuery.grep()用法及代碼示例
- JQuery Mobile jQuery.mobile.navigate()用法及代碼示例
- JQuery Mobile jQuery.mobile.path.isRelativeUrl()用法及代碼示例
- JQuery jQuery.dequeue()用法及代碼示例
- JQuery Mobile jQuery.mobile.silentScroll()用法及代碼示例
- JQuery jQuery.cssNumber用法及代碼示例
- JQuery jQuery.map()用法及代碼示例
- JQuery jQuery.readyException()用法及代碼示例
- JQuery jQuery.parseJSON()用法及代碼示例
- JQuery jQuery.contains()用法及代碼示例
- JQuery Mobile jQuery.mobile.path.makePathAbsolute()用法及代碼示例
- JQuery jQuery.unique()用法及代碼示例
- JQuery jQuery.getJSON()用法及代碼示例
- JQuery jQuery.proxy()用法及代碼示例
- JQuery jQuery.ajaxSetup()用法及代碼示例
- JQuery jQuery.type()用法及代碼示例
- JQuery jQuery.cssHooks用法及代碼示例
- JQuery jQuery.parseXML()用法及代碼示例
注:本文由純淨天空篩選整理自jqueryui.com大神的英文原創作品 jQuery.effects.define()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。