.focusout()
.focusout( handler(eventObject) ) 返回: jQuery
描述: 將一個事件函數(shù)綁定到"focusout" 事件。
-
version added: 1.4.focusout( handler(eventObject) )
handler(eventObject)每次事件觸發(fā)時會執(zhí)行的函數(shù)。
-
version added: 1.4.3.focusout( [ eventData ], handler(eventObject) )
eventData將要傳遞給事件處理函數(shù)的數(shù)據(jù)映射。
handler(eventObject)每次事件觸發(fā)時會執(zhí)行的函數(shù)。
這個方法是 .bind('focusout', handler)
的快捷方式。
focusout
事件會在元素(或者其內部的任何元素)失去焦點焦點時觸發(fā)。這跟 blur 事件的顯著區(qū)別在于,它可以在父元素上檢測子元素失去焦點的情況(換而言之,它支持事件冒泡)。
這個事件通常會跟 focusin 事件一起使用。
Example:
Watch for a loss of focus to occur inside paragraphs and note the difference between the focusout count and the blur count.
<!DOCTYPE html>
<html>
<head>
<style>
.inputs { float: left; margin-right: 1em; }
.inputs p { margin-top: 0; }
</style>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<div class="inputs">
<p>
<input type="text" /><br />
<input type="text" />
</p>
<p>
<input type="password" />
</p>
</div>
<div id="fo">focusout fire</div>
<div id="b">blur fire</div>
<script>
var fo = 0, b = 0;
$("p").focusout(function() {
fo++;
$("#fo")
.text("focusout fired: " + fo + "x");
}).blur(function() {
b++;
$("#b")
.text("blur fired: " + b + "x");
});
</script>
</body>
</html>