亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

js 判斷控件獲得焦點(diǎn)的示例代碼

 更新時(shí)間:2014年03月04日 09:09:58   作者:  
本篇文章主要是對(duì)js 判斷控件獲得焦點(diǎn)的示例代碼進(jìn)行了介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助

JS判斷一個(gè)對(duì)象已獲得焦點(diǎn)document.activeElement.tagName //tagName 標(biāo)簽名

實(shí)例:判斷body獲得光標(biāo)時(shí)關(guān)閉輸入法。

復(fù)制代碼 代碼如下:

var act = document.activeElement.tagName.toLowerCase();
   if(act.indexOf("body") != -1 || act.indexOf("html") != -1)
   {
    document.body.style.imeMode = 'disabled';
   }

<script>
function test(){
var srcElem = document.activeElement
var testval = srcElem.name; //id和name比較常用應(yīng)該
alert("控件"+testval+"獲取焦點(diǎn)");
}
</script>

<input name="a" type="text" value="測(cè)試a" onclick="test();">
<input name="b" type="text" value="測(cè)試b" onclick="test();">

相關(guān)文章

最新評(píng)論