java script old
<script> // Find out the cart items from localStorage if (localStorage.getItem('cart') == null) { var cart = {}; } else { cart = JSON.parse(localStorage.getItem('cart')); document.getElementById('cart').innerHTML = Object.keys(cart).length; updateCart(cart); } // If the add to cart button is clicked, add/increment the item function addToCart(event){ // $('.divpr').on('click', 'button.cart', function(){ var idstr = event.target.id; if (cart[idstr] != undefined) { qty = cart[idstr][0] + 1; } else { qty = 1; name = document.getElementById('name'+idstr).innerHTML price = document.getElementById('price'+idstr).innerHTML cart[idstr] = [qty, name,price]; } updateCart(cart); ...