Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

158
Vistas
replace document.getElementbyId("id") with just id

It seems that this code is working well. Please try it out before you answer:

    <!DOCTYPE html>
<html>
<body>
<h2>JavaScript Variables</h2>
<p>In this example, x, y, and z are variables.</p>
<p id="demo"></p>
<script>
let x = 7;
let y = 45;
let z = x + y;
demo.innerHTML = "The value of z is: " + z;//please note this line
</script>
</body>
</html>

Does this mean that I can replace document.getElementById("id"). with just id.???

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

It's working but it's considered legacy and unsafe.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Seems like it does, and it works for nested elements also... I wonder though if it works on a different js file imported from the html.

<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Variables</h2>
<p>In this example, x, y, and z are variables.</p>
<p id="demo1">
  <p id="demo2"></p>
</p>
<p id="demo"></p>
<script>
let x = 7;
let y = 45;
let z = x + y;
demo.innerHTML = "The value of z is: " + z;//please note this line

demo2.innerHTML = "The value of z is: " + z;//please note this line
console.log(demo);
</script>
</body>
</html>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda