如何使输入自动对焦在互联网浏览器? [英] How to make input autofocus in internet explorer?
本文介绍了如何使输入自动对焦在互联网浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请检查我的jsfiddle
Please check out my jsfiddle
http://jsfiddle.net/ WK2N3 / 1 /
如何在自动对焦上进行此操作,就像Chrome,safari,opera和firefox for IE?
How can I make this on autofocus like it is for chrome, safari, opera and firefox for IE?
推荐答案
这里是一个单线程(well,一行实际逻辑),使用jQuery使自动对焦工作在IE。
Here's a one-liner (well, one line of actual logic) that uses jQuery to make autofocus work in IE. It bails out if the focus is already set--in other words, in any HTML5-capable browser.
$(function() {
$('[autofocus]:not(:focus)').eq(0).focus();
});
我解释了它的工作原理。而这里是在IE中更新的jsFiddle。
I explained how it works in my blog. And here is an updated jsFiddle that works in IE.
这篇关于如何使输入自动对焦在互联网浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文