HTML DOM focus () method
Definitions and use
focus () method is used to set the focus (if set) for the element.
Tip: Use the blur () method to remove the element of focus.
Browser Support
方法 | |||||
---|---|---|---|---|---|
focus() | Yes | Yes | Yes | Yes | Yes |
grammar
HTMLElementObject .focus ()
parameter
None |
Technical Description
return value: | No return value |
---|
More examples
Examples
After the document is loaded, set the focus to a text field:
window.onload = function () {
document.getElementById ( "myText") .focus ( );
};
document.getElementById ( "myText") .focus ( );
};
try it"
Related Pages
HTML DOM Reference Manual: the onfocus event