Element.id
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
La propiedad Element.id
representa el identificador del elemento, reflejando el atributo global de id.
debe ser un único documento, y con frecuencia es utilizado para recuperar el elemento usando getElementById
. Otros usos comunes de id
incluyen la utilización de elementos ID como un selector cuando se está estilando el documento con CSS.
Nota: Los identificadores distinguen mayúsculas y minúsculas, pero se debe evitar la creación de IDs que difieran solamente en la capitalization (ver diferenciación de mayúsculas y minúsculas en nombres y destacados).
Síntaxis
var idStr = elt.id; // Get the id.
elt.id = idStr; // Set the id
idStr
es el identificador del elemento.
Especificaciones
Specification |
---|
DOM # ref-for-dom-element-id① |
Compatibilidad con navegadores
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
id |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Partial support
- Partial support
- Has more compatibility info.
Véase también
- La id del atributo global DOM.