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

126
Vistas
can <span id="textArea1"></span> be re-used in the DOM?

I wrote a simple NodeJS/express API, serving a single HTML page. The page contains a javascript form, sending a date to the server using axios. The server does calculations and sends back a response. The response is then cut into bits, with their values written as .innerHTML "id"s.

                axios({
                        method: "post",
                        url: "/",
                        data: data,
                    })
                    .then((res) => {
                        document.getElementById("textArea1").innerHTML = res.data.earth.lon;
                        document.getElementById("textArea2").innerHTML = res.data.earth.lat;

I noticed that each "id" can be used only once in the body. If I write the same line twice (notice the "textArea1") :

    <p> longitude: <span id="textArea1"></span>&deg;</p>
    <p> longitude: <span id="textArea1"></span>&deg;</p>

... only the first one gets a value.

I guess the "id" is unique in the DOM and cannot be re-used ? I don't need it twice, I just noticed this doing some copy-paste.

Would there be a simple way, if I needed to use the same "id" twice ?

Thanks, Lorenzo

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

0

The reason why use unique ids is for your browser, and you as a developer handle correctly the dom element and avoid many problems.

Figure out your neighborhood, a house with same postal code, number will be very hard to ensure that postal deliver have sure if the house is correct.

You will not disallowed create elements with ids equal but you want avoid It.

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