HTML DOM idPropiedad
Definición y uso
La propiedad id establece o devuelve el id de un elemento.
Sintaxis
HTMLElementObject.id=id
Soporte del navegador
![]()
![]()
![]()
![]()
![]()
Todos los navegadores principales soportan la propiedad id.
Ejemplo
Ejemplo
Salida del id del enlace:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial para novatos (example.com)</title>
</head>
<body>
<p><a id="myAnchor" href="//www.example.com">Visita Tutorial para novatos</a></p>
<script>
var x=document.getElementById("myAnchor");
document.write(x.id);
</script>
</body>
</html>
Pruébalo »
Otras extensiones
Objeto de elemento