我有一个带有文本框的网络表单.默认情况下如何将焦点设置到文本框?
I have a web form with a text box in it. How do I go about setting focus to the text box by default?
类似这样的:
<body onload='setFocusToTextBox()'>
所以有人可以帮我吗?我不知道如何使用 JavaScript 将焦点设置到文本框.
so can anybody help me with it? I don't know how to set focus to the text box with JavaScript.
<script>
function setFocusToTextBox(){
//What to do here
}
</script>
这样做.
如果你的元素是这样的..
If your element is something like this..
<input type="text" id="mytext"/>
你的脚本是
<script>
function setFocusToTextBox(){
document.getElementById("mytext").focus();
}
</script>
这篇关于如何使用 JavaScript 将焦点设置在 HTML 表单中的元素上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
检查一个多边形点是否在传单中的另一个内部Check if a polygon point is inside another in leaflet(检查一个多边形点是否在传单中的另一个内部)
更改传单标记群集图标颜色,继承其余默认 CSSChanging leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改传单标记群集图标颜色,继承其余默认
触发点击传单标记Trigger click on leaflet marker(触发点击传单标记)
如何更改 LeafletJS 中的默认加载磁贴颜色?How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默认加载磁贴颜色?)
将 Leaflet 图层控件添加到侧边栏Adding Leaflet layer control to sidebar(将 Leaflet 图层控件添加到侧边栏)
Leaflet - 在弹出窗口中获取标记的纬度和经度Leaflet - get latitude and longitude of a marker inside a pop-up(Leaflet - 在弹出窗口中获取标记的纬度和经度)