How to place mouse cursor to certain input box
How ca开发者_如何学Cn I place the cursor automaticly to certain input box. This would help to not use the mouse all the time when open the page. (php and html)
Thank you!
<input name="input1" id="input1" value="" />
window.onload = init;
function init(){
document.getElementById("input1").focus();
}
This should do
window.onload = function(){
document.getElementById("InputBoxID").focus();
};
Use the focus()
method of the input on body.onLoad
.
<input type="text" autofocus="autofocus" name="FirstName"/>
Text Field Get Focused When Page Gets Loaded..
For More Info, Check This Autofocus-Attribute Link
精彩评论