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

119
Views
Cambiar evento en el botón

Estoy tratando de ordenar una matriz en un evento de cambio aplicado a un botón, pero parece que nunca entro en este detector de eventos.

¿Cuál podría ser posiblemente el problema? Gracias por adelantado

 <div class="sort"> <button class="sorting" value="popular"><span class="sortby">Popular</span></button> <div class="choices"> <button class="choice" value="popular">Popular</button> <button class="choice" value="date">Date</button> <button class="choice" value="title">Title</button> </div> </div>
 const photos = ["abc", "def", "abf", "abdc", "152"] const sortBtn = document.querySelector(".sorting") const sortBy = document.querySelector(".sortby") const choices = document.querySelector(".choices") const singleChoice = document.querySelectorAll(".choice") singleChoice.forEach((choice, index) => { //click on a choice choice.addEventListener("click", () => { sortBtn.value = choice.value sortBy.textContent = choice.value console.log("sortbutton value",sortBtn.value) //Onchange sort sortBtn.addEventListener("change", () => { if(sortBtn.value == "date") { photos.sort() console.log(photos) } }) }) })
about 4 years ago · Juan Pablo Isaza
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!