Nuestros voluntarios aún no han traducido este artículo al Español. Únete a nosotros y ayúdanos a traducirlo
The HTMLElement.focus()
method sets focus on the specified element, if it can be focused.
Syntax
element.focus()
Specification
Specification | Status | Comment |
---|---|---|
WHATWG HTML Living Standard The definition of 'focus' in that specification. |
Living Standard | |
HTML5.1 The definition of 'focus' in that specification. |
Working Draft | |
HTML5 The definition of 'focus' in that specification. |
Recommendation | |
Document Object Model (DOM) Level 2 HTML Specification The definition of 'focus' in that specification. |
Recommendation | |
Document Object Model (DOM) Level 1 Specification The definition of 'focus' in that specification. |
Recommendation |
Notes
If you call HTMLElement.focus()
from a mousedown event handler, you must call event.preventDefault()
to keep the focus from leaving the HTMLElement
.
See also
- DOM method
HTMLElement.blur()
to remove the focus from an element. document.activeElement
to know which is the currently focused element.
Etiquetas y colaboradores del documento
Etiquetas:
Colaboradores en esta página:
jakobc,
rittmeyer,
swick7,
fscholz,
teoli,
saneyuki_s,
ajaybhat,
kscarfone,
Sheppy,
tregagnon,
mattbasta,
ziyunfei,
Nickolay,
another_sam,
Bzbarsky,
Mgjbot,
Gopi,
Ptak82,
Dria,
Callek,
JesseW
Última actualización por:
jakobc,