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.