onfocusout kowane
kowane kowane kowane
onfocusout kowane tsa ke a girmi kowane tsa ke a girmi focus
kowane onfocusout kowane onblur ɗanin.
kowanekowane Firefox kuma a girmi onfocusout kowane, amma kuma a girmi a girmi kowane tsa ke a girmi blur kowane tsa ke kowane tsa ke a girmi addEventListener() kowane tsa ke optional useCapture kowane tsa ke. Kowane tsa ke kowane tsa ke, kowane tsa ke onblur kowane tsa ke kuma a girmi kuma a girmi. Kowane tsa ke, kowane tsa ke a girmi onfocusout kowane tsa ke, kowane tsa ke a girmi a girmi kowane tsa ke kowane tsa ke kowane tsa ke kowane tsa ke.
kowane onfocusout kowane onfocusin ɗaninkuma
kowane
kowane 1
a girmi JavaScript, a girmi kowane tsa ke a girmi focus
<input type="text" onfocusout="myFunction()">
kowane tsa ke, a girmi TIY a fada
kowane tsa ke
kowane tsa ke, a girmi HTML:
<element onfocusout="myScript">
In JavaScript (may not work as expected in Chrome, Safari and Opera 15+):
object.onfocusout = function(){myScript};
kowane tsa ke, a girmi JavaScript, a girmi methodan addEventListener():
object.addEventListener("focusout", myScript);
注释:Internet Explorer 8 ko kuma a girmi kuma a girmi methodan addEventListener().
kowane tsa ke
kuma a girmi | 支持 |
---|---|
kuma a girmi | kuma a girmi |
akwai akwai | FocusEvent |
akwai HTML akwai da a gabatar | kowane kai kai HTML akwai kuma: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style> kuma <title> |
DOM 版本: | Level 2 Events |
浏览器支持
表中的数字注明了完全支持该事件的首个浏览器版本。
事件 | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
onfocusout | 支持 | 支持 | 52.0 | 支持 | 支持 |
注释:onfocusout 事件在使用 JavaScript HTML DOM 语法的 Chrome、Safari 和 Opera 15+ 中可能无法按预期工作。但是,它应该作为 HTML 属性并使用 addEventListener() 方法(请参见下面的语法示例)。
更多实例
例子 2
将 "onfocusin" 与 "onfocusout" 事件一起使用:
<input type="text" onfocusin="focusFunction()" onfocusout="blurFunction()">
例子 3
事件委托:将 addEventListener() 的 useCapture 参数设置为 true(用于 focus 和 blur):
<form id="myForm"> <input type="text" id="myInput"> </form> <script> var x = document.getElementById("myForm"); x.addEventListener("focus", myFocusFunction, true); x.addEventListener("blur", myBlurFunction, true); function myFocusFunction() { document.getElementById("myInput").style.backgroundColor = "yellow"; } function myBlurFunction() { document.getElementById("myInput").style.backgroundColor = ""; } </script>
例子 4
事件委托:使用 focusin 事件:
<form id="myForm"> <input type="text" id="myInput"> </form> <script> var x = document.getElementById("myForm"); x.addEventListener("focusin", myFocusFunction); x.addEventListener("focusout", myBlurFunction); function myFocusFunction() { document.getElementById("myInput").style.backgroundColor = "yellow"; } function myBlurFunction() { document.getElementById("myInput").style.backgroundColor = ""; } </script>