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

117
Views
¿Cómo puedo verificar si el contenido del texto en la página cambió?

Quiero verificar si el contenido de texto en el carrito de var cambia en esta página: https://www.supremenewyork.com/shop/all

 let cart = document.getElementById('items-count').textContent; console.log(cart); cart.addEventListener('change', function() { console.log("cart"); window.location.replace("http://stackoverflow.com"); });

me sale este error

TypeError no detectado: cart.addEventListener no es una función en Chrome-extension://ljhadajgdcijdfoopfbkjibfebkilieh/supreme.js:11:6

El script comienza cuando entro en la página.

Ya intenté monitorearlo con un ciclo while como en el siguiente código, pero luego el sitio web se congela y no puedo usarlo más hasta que cambie la var.

 let carted = 0 let cart = document.getElementById('items-count').textContent; while (carted < 1 ) { console.log(cart); if (cart.length > 2) { cart ++; window.location.replace("http://stackoverflow.com"); } }
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Porque está tratando de agregar un detector de eventos al contenido de texto de su textContent , no a su elemento, y no puede hacerlo. solo haz esto

 let cart = document.getElementById('items-count'); console.log(cart); cart.addEventListener('change', function() { console.log(`cart content has changed — ${cart.textContent}`); window.location.replace("http://stackoverflow.com"); });
about 4 years ago · Juan Pablo Isaza Report

0

Si desea agregar un oyente, no puede hacerlo en textContent .

 let cart = document.getElementById('items-count'); //.textContent console.log(cart); cart.addEventListener('change', function() { console.log("cart"); window.location.replace("http://stackoverflow.com"); });

Si necesita ese valor, puede almacenarlo en otra variable:

 var content = cart.textContent
about 4 years ago · Juan Pablo Isaza Report

0

Tú podrías

 var item = document.getElementById('items-count'); item.addEventListener("change", DoStuff); function DoStuff(){ //do what do you want to do. }
about 4 years ago · Juan Pablo Isaza 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!