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

194
Vistas
Why people are using getElementById instead of accessing elements directly?

In every single tutorial I have seen that using document.getElementById(id); is recommended, but it's longer than just accessing the elements directly by their IDs. Example code that is perfectly functional:

<script>
    function appendText() {
        foo.innerHTML += bar.value
    }
</script
<div>
    <p id="foo"></p>
    <input type="text" id="bar" />
    <button onclick="appendText()">Add</button> 
</div>

What are disadvantages of accessing elements like that, and why nobody is using it that way? For me it was always more handy to do this that way. Or maybe people just don't know that there is such a possibility?

about 4 years ago · Juan Pablo Isaza
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