色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

ie focus bug 解決方法

如果把input.focus()放在一個(gè)setTimeout中延時(shí)執(zhí)行,則就可以獲得焦點(diǎn)。
復(fù)制代碼 代碼如下:
<script type="text/Javascript" >
(function(){
function get(id){
return document.getElementById(id);
}
window.onload = function(){
get('makeinput').onmousedown = function(){
var input = document.createElement('input');
input.setAttribute('type', 'text');
input.setAttribute('value', 'test1');
get('inpwrapper').appendChild(input);
input.focus();
input.select();
}
get('makeinput2').onmousedown = function(){
var input = document.createElement('input');
input.setAttribute('type', 'text');
input.setAttribute('value', 'test1');
get('inpwrapper2').appendChild(input);
setTimeout(function(){
input.focus();
input.select();
}, 0);
}
get('input').onkeypress = function(){
get('preview').innerHTML = this.value;
}
}
})();
</script>
<h1><code>setTimeout</code></h1>
<h2>1、未使用 <code>setTimeout</code></h2>
<button id="makeinput">生成 input</button>
<p id="inpwrapper"></p>
<h2>2、使用 <code>setTimeout</code></h2>
<button id="makeinput2">生成 input</button></h2>
<p id="inpwrapper2"></p>
<h2>3、另一個(gè)例子</h2>
<p><input type="text" id="input" value=""/><span id="preview"></span></p>

JavaScript技術(shù)ie focus bug 解決方法,轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 兴化市| 修水县| 涪陵区| 老河口市| 东丰县| 林西县| 灵璧县| 博湖县| 花莲县| 肃宁县| 沾化县| 新乡县| 宜君县| 韩城市| 全椒县| 饶平县| 绩溪县| 邵武市| 报价| 镇原县| 辉县市| 北宁市| 北京市| 璧山县| 遂川县| 四川省| 夏河县| 台东市| 岳普湖县| 芦溪县| 肇源县| 大余县| 嵩明县| 绥阳县| 宜阳县| 孝感市| 新泰市| 柳江县| 博乐市| 淮南市| 南和县|