-
Notifications
You must be signed in to change notification settings - Fork 260
Expand file tree
/
Copy pathblur.xml
More file actions
86 lines (83 loc) · 3.6 KB
/
blur.xml
File metadata and controls
86 lines (83 loc) · 3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?xml version="1.0"?>
<entries>
<desc>Bind an event handler to the "blur" event, or trigger that event on an element.</desc>
<entry type="method" name="on" return="jQuery">
<title>blur event</title>
<desc>Bind an event handler to the "blur" event.</desc>
<signature>
<added>1.7</added>
<argument name=""blur"" type="string">
<desc>The string <code>"blur"</code>.</desc>
</argument>
<argument name="eventData" type="Anything" optional="true">
<desc>An object containing data that will be passed to the event handler.</desc>
</argument>
<argument name="handler" type="Function">
<desc>A function to execute each time the event is triggered.</desc>
<argument name="eventObject" type="Event" />
</argument>
</signature>
<longdesc>
<div class="warning">
<p>This page describes the <code>blur</code> event. For the deprecated <code>.blur()</code> method, see <a href="/blur-shorthand/"><code>.blur()</code></a>.</p>
</div>
<p>The <code>blur</code> event is sent to an element when it loses focus. Originally, this event was only applicable to form elements, such as <code><input></code>. In recent browsers, the domain of the event has been extended to include all element types. An element can lose focus via keyboard commands, such as the Tab key, or by mouse clicks elsewhere on the page.</p>
<p>For example, consider the HTML:</p>
<pre><code>
<form>
<input id="target" type="text" value="Field 1">
<input type="text" value="Field 2">
</form>
<div id="other">
Trigger the handler
</div>
</code></pre>
<p>The event handler can be bound to the first input field:</p>
<pre><code>
$( "#target" ).on( "blur", function() {
alert( "Handler for `blur` called." );
} );
</code></pre>
<p>Now if the first field has the focus, clicking elsewhere or tabbing away from it displays the alert:</p>
<p>
<samp>Handler for `blur` called.</samp>
</p>
<p>To trigger the event programmatically, call <code>.trigger( "blur" )</code>:</p>
<pre><code>
$( "#other" ).on( "click", function() {
$( "#target" ).trigger( "blur" );
} );
</code></pre>
<p>After this code executes, clicks on <samp>Trigger the handler</samp> will also alert the message.</p>
<p>The <code>blur</code> event does not bubble. As of version 1.4.2, jQuery works around this limitation by mapping <code>blur</code> to the <code>focusout</code> event in its event delegation methods.</p>
<p>The native <code>blur</code> event is asynchronous in all versions of IE, contrary to other browsers. To avoid issues related to this discrepancy, as of jQuery 3.7.0, jQuery uses <code>focusout</code> as the native backing event for <code>blur</code> in IE.</p>
</longdesc>
<example>
<desc>To trigger the blur event on all paragraphs:</desc>
<code><![CDATA[
$( "p" ).trigger( "blur" );
]]></code>
</example>
<category slug="events/form-events"/>
<category slug="forms"/>
<category slug="version/1.0"/>
<category slug="version/1.7"/>
<category slug="version/3.7"/>
</entry>
<entry type="method" name="trigger" return="jQuery">
<title>blur event</title>
<desc>Trigger the "blur" event on an element.</desc>
<signature>
<added>1.0</added>
<argument name=""blur"" type="string">
<desc>The string <code>"blur"</code>.</desc>
</argument>
</signature>
<longdesc>
<p>See the description for <a href="#on1"><code>.on( "blur", ... )</code></a>.</p>
</longdesc>
<category slug="events/form-events"/>
<category slug="forms"/>
<category slug="version/1.0"/>
</entry>
</entries>