Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

209
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!