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

150
Vistas
How to stop inputA from changing?

so how can i make inputA and inputB have different numbers? right now inputA is the same as inputB ‎‎‎‎‎‎‎‎‎‎‎

const numbers = document.querySelectorAll(".numbers");
numbers.forEach((number) => {
  number.addEventListener("click", () => {
    display.textContent += number.innerHTML;
    inputA = display.textContent;
    console.log(inputA + "a")
  });
});

const functions = document.querySelectorAll(".func");
functions.forEach((fnction) => {
  fnction.addEventListener("click", () => {
    display.textContent = "";
    operatorInput = fnction.innerHTML;
    console.log(operatorInput)

    
      numbers.forEach((number) => {
      number.addEventListener("click", () => {
        
        inputB = display.textContent;
        console.log(inputB + "b");
      });
    });

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

0

First of all document.querySelectorAll doesnt return array. The proper usage is:

Array.from(document.querySelectorAll(selector)).forEach... 

Please check the reference https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll

You dont declare variables inputA and inputA (let inputA, let inputB). What's more, display.textContent in case B is equal to the display.textcontent from the case A. Because it's the same element. Despite you attempt to clear textContent in the upperscope (case B) it has no effect.

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