Met Html Focus
# HTML DOM focus() Method
[ Element Object](#)
## Example
Set focus on an element:
document.getElementById("myAnchor").focus();
[Try it Β»](#)
* * *
## Definition and Usage
The focus() method is used to set focus on an element (if it can be set).
**Tip:** Use the [blur()](#) method to remove focus from an element.
* * *
## Browser Support
| Method | | | | | |
| --- | --- | --- | --- | --- | --- |
| focus() | Yes | Yes | Yes | Yes | Yes |
* * *
## Syntax
_HTMLElementObject_.focus()
## Parameters
None
## Technical Details
| Return Value: | No return value |
| --- |
* * *

## More Examples
## Example
Set focus on a text field:
document.getElementById("myText").focus();
[Try it Β»](#)
## Example
Set focus on a text field after the document has loaded:
window.onload = function() {
document.getElementById("myText").focus();
};
[Try it Β»](#)
* * *
## Related Pages
HTML DOM Reference: (#)
* * Element Object](#)
YouTip