HTML DOM Element focus() method
- Προηγούμενη σελίδα firstElementChild
- Επόμενη σελίδα getAttribute()
- Επιστροφή στο προηγούμενο επίπεδο HTML DOM Elements οντόν
Definition and usage
focus()
Method to make an element obtain focus (if it is focusable).
See also:
Instance
Example 1
Focus on an element:
document.getElementById("myAnchor").focus();
Example 2
Place the focus on the text field:
document.getElementById("myText").focus();
Example 3
After the document is loaded, place the focus on the text field:
window.onload = function() { document.getElementById("myText").focus(); }
Syntax
element.focus()
Parameter
None.
Return value
None.
Browser support
element.focus()
It is a DOM Level 2 (2001) feature.
All browsers fully support it:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Υποστήριξη | 9-11 | Υποστήριξη | Υποστήριξη | Υποστήριξη | Υποστήριξη |
- Προηγούμενη σελίδα firstElementChild
- Επόμενη σελίδα getAttribute()
- Επιστροφή στο προηγούμενο επίπεδο HTML DOM Elements οντόν