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

226
Vistas
manage event, with addEventListener, and select dynamic input with querySelectorAll

Sorry it's look like repost but I dont saw my answer in the others topics. I need to make dynamic website witch offer possibility to order some product by the Local Storage.

The client can select product and theses are show to my card.html, forEach product of my LS I made an article.

In this article there's a child, an input showing the quantity selected before by client. I would like link this input to my local storage. Client will change directly the quantity in this order page, and if there's change, he's report to my local Storage.

here there's my test function.

const manageQuantity = async (createArticle) => {
    await createArticle
    
    let itemQuantity = document.querySelector('.itemQuantity')
    console.log(itemQuantity)

    itemQuantity.addEventListener('change', () => {
        console.log("ok l'évènement est fonctionnel")
    })
}
// createArticle, make the article if I've product in LS
// itemQuantity is the class of my input

My addEventListener's not a function with quereSelectorAll, but he is with a simple querySelector. But I need to have all input created by my function.

How can I select all my input, and be sure my addEvent will running ?

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

const manageQuantity = async (createArticle) => {
    await createArticle
    
    let itemQuantities = document.querySelectorAll('.itemQuantity')
    
    
    itemQuantities .forEach(function(item) {
      item.addEventListener('change', () => {
        console.log("ok l'évènement est fonctionnel")
      })
    });
    

}

basically you should use querySelectorAll() if you are using class it will return a node list so you can use the foreach function to loop through all of the elements with the selected class and add the event listeners

about 4 years ago · Santiago Gelvez 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