Cart with Live Total
A mini cart where quantity changes recalculate the grand total.
Requires Bootstrap 5. Add the CDN tags below to your page (styles in
<head>, scripts before </body>). The downloaded file already includes them.<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script><div class="card border-0 shadow-sm" style="max-width:340px"><div class="card-body"><div class="d-flex justify-content-between align-items-center mb-2"><span class="small">Keyboard ($59)</span><div class="input-group input-group-sm" style="width:100px"><button class="btn btn-outline-secondary" data-q="-" data-p="59">−</button><input class="form-control text-center" value="1" readonly data-qty><button class="btn btn-outline-secondary" data-q="+" data-p="59">+</button></div></div><hr><div class="d-flex justify-content-between fw-bold"><span>Total</span><span id="qcTotal">$59</span></div></div></div>var qty=1,p=59,el=document.querySelector("[data-qty]"),tot=document.getElementById("qcTotal");document.querySelectorAll("[data-q]").forEach(function(b){b.onclick=function(){qty=Math.max(1,qty+(b.dataset.q==="+"?1:-1));el.value=qty;tot.textContent="$"+(qty*p)}});Free to use.This component uses Bootstrap 5 (linked above). Copy any file, or download a ready-to-open .html page with the CDN links already included.