[英]The fastest way to set the focus on a textfield
将焦点放在文本字段上的最快(最快)方法是什么?
我的页面看起来像
<html>
<head> ... </head>
<body>
... content ...
<input type="text" id="ct_one" name="ct_pet[]" value="" />
... content ...
<script> ... load jquery and jquery_ui ... </script>
</body>
</html>
提前致谢!
彼得
您可以在元素后面放置一个脚本,将焦点设置到该元素。 这将在尽可能早的时刻设定焦点,即在元素创建之后。
<input type="text" id="ct_one" name="ct_pet[]" value="" />
<script type="text/javascript">
document.getElementById('ct_one').focus();
</script>
将值0分配给输入字段的属性tabindex。
http://www.w3.org/TR/html4/interact/forms.html#adef-tabindex
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.