久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      javascript怎么判斷元素是否有焦點

      在JavaScript中,可用onfocus()和onblur()事件判斷元素是否有焦點,onfocus事件在元素獲取焦點時發(fā)生,onblur事件在元素失去焦點時發(fā)生,語法為“<element onfocus="Function()">”。

      javascript怎么判斷元素是否有焦點

      本教程操作環(huán)境:windows10系統(tǒng)、javascript1.8.5版、Dell G3電腦。

      javascript怎么判斷元素是否有焦點

      onfocus 事件在對象獲得焦點時發(fā)生。

      Onfocus 通常用于 <input>, <select>, 和<a>.

      提示: onfocus 事件的相反事件為 onblur 事件。

      語法

      HTML 中:

      <element onfocus="SomeJavaScriptCode">

      JavaScript 中:

      object.onfocus=function(){SomeJavaScriptCode}

      JavaScript 中, 使用 addEventListener() 方法:

      object.addEventListener("focus", myScript);

      onblur 事件會在對象失去焦點時發(fā)生。

      Onblur 經(jīng)常用于Javascript驗證代碼,一般用于表單輸入框。

      提示:onblur 相反事件為 onfocus 事件 。

      語法

      HTML 中:

      <element onblur="SomeJavaScriptCode">

      JavaScript 中:

      object.onblur=function(){SomeJavaScriptCode};

      示例如下:

      <!DOCTYPE html> <html> <head> <meta charset="utf-8">  <title>菜鳥教程(runoob.com)</title> <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"> </script> <script> function Function(){ document.getElementById('tip').innerHTML='元素失去焦點了'; } function myFunction(x){ document.getElementById('tip').innerHTML='元素獲取焦點了'; } </script> </head> <body> 判斷焦點示例: <input type="text" onfocus="myFunction(this)" onblur="Function()"> <p id="tip" style="color:red;"></p> </body> </html>

      輸出結(jié)果:

      javascript怎么判斷元素是否有焦點

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號