aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/globaleventhandlers/onblur
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/globaleventhandlers/onblur
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/globaleventhandlers/onblur')
-rw-r--r--files/zh-cn/web/api/globaleventhandlers/onblur/index.html81
1 files changed, 81 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/globaleventhandlers/onblur/index.html b/files/zh-cn/web/api/globaleventhandlers/onblur/index.html
new file mode 100644
index 0000000000..221b679239
--- /dev/null
+++ b/files/zh-cn/web/api/globaleventhandlers/onblur/index.html
@@ -0,0 +1,81 @@
+---
+title: GlobalEventHandlers.onblur
+slug: Web/API/GlobalEventHandlers/onblur
+tags:
+ - Gecko DOM Reference
+translation_of: Web/API/GlobalEventHandlers/onblur
+---
+<div>{{ ApiRef("HTML DOM") }}</div>
+
+<h3 id="Summary" name="Summary">概述</h3>
+
+<p><strong>onblur</strong>属性用来获取或设置当前元素的onBlur事件的事件处理函数</p>
+
+<h3 id="Syntax" name="Syntax">语法</h3>
+
+<pre class="eval">element.onblur = function;
+</pre>
+
+<ul>
+ <li><code>function</code> 是一个函数名, 没有括号()和任何参数,也可以是一个匿名函数,如下:</li>
+</ul>
+
+<pre class="eval">element.onblur = function() { alert("检测到onblur事件!"); };
+</pre>
+
+<h3 id="Example" name="Example">例子</h3>
+
+<pre>&lt;html&gt;
+
+&lt;head&gt;
+&lt;title&gt;onblur event example&lt;/title&gt;
+
+&lt;script type="text/javascript"&gt;
+
+var elem = null;
+
+function initElement()
+ {
+ elem = document.getElementById("foo");
+ // 注意:doEvent() 和 doEvent(param)都是不正确的.这里只能是函数名,不能是函数调用.
+ elem.onblur = doEvent;
+ };
+
+function doEvent()
+ {
+ elem.value = 'Bye-Bye';
+ alert("检测到onblur事件!")
+ }
+&lt;/script&gt;
+
+&lt;style type="text/css"&gt;
+&lt;!--
+#foo {
+border: solid blue 2px;
+}
+--&gt;
+&lt;/style&gt;
+&lt;/head&gt;
+
+&lt;body onload="initElement()";&gt;
+&lt;form&gt;
+&lt;input type="text" id="foo" value="Hello!" /&gt;
+&lt;/form&gt;
+
+&lt;p&gt;点击input元素使其获得焦点,然后点击其他页面其他部位&lt;/p&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
+</pre>
+
+<h3 id="Notes" name="Notes">备注</h3>
+
+<p>当一个元素失去焦点时会触发<code>blur</code>事件.</p>
+
+<p>在IE中,几乎所有类型的元素都可以触发blur事件,但在基于gecko的浏览器中,大部分元素都不能触发blur事件.</p>
+
+<h3 id="Specification" name="Specification">规范</h3>
+
+<p>DOM Level 0不属于任何规范.</p>
+
+<p>{{ languages( {"fr": "fr/DOM/element.onblur","en": "en/DOM/element.onblur" } ) }}</p>