die
英[da?] 美[da?]
vt.& vi. Death, extinguishing; withering, withering; desire, hope
n.Steel type, die; dice
jquery die() method syntax
Function: The die() method removes all one or more event handlers added to the specified element through the live() method.
Syntax: $(selector).die(event,function)
Parameters:
Parameters | Description |
event | Required. Specifies one or more event handlers to be removed. Multiple event values ??separated by spaces. Must be a valid event. |
function | Optional. Specifies specific functions to be removed. |
## jquery die() method example
<html>
<head>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("p").live("click",function(){
$(this).slideToggle();
});
$("button").click(function(){
$("p").die();
});
});
</script>
</head>
<body>
<p>這是一個段落。</p>
<p>這是另一個段落。</p>
<p>請點擊任意 p 元素,段落會消失。包括本段落。</p>
<button>移除通過 live() 方法向 p 元素添加的事件處理程序</button>
</body>
</html>
Run instance ?Click the "Run instance" button to view the online instance