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

179
Vistas
product:567 Uncaught TypeError: Cannot read properties of undefined (reading 'getElementsByClassName')

Please someone help me out with this

function updatetotal(){
   var cartContent = document.getElementsByClassName('cart-content')[0];   
   console.log(cartContent);

Whenever i run this function via another function given below cart-content class is undefined

function addCartClicked(event){
   var button = event.target
   var shopProducts = button.parentElement.parentElement
   var title = shopProducts.getElementsByClassName('product-title')[0].innerText;
   var price = shopProducts.getElementsByClassName('price')[0].innerText;
   var productImg = shopProducts.getElementsByClassName('product-img')[0].src;
   console.log(title,price,productImg);
   updatetotal();    }

the second function uses classes from diffrent html file and the first one uses classes from diffrent one and both of them have the same js file all functions are working independently but i cant make them work combined.

about 4 years ago · Juan Pablo Isaza
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