Like & Save Buttons
Like and save buttons with live count and toggle states.
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:300px"><div class="card-body d-flex align-items-center gap-3">
<button class="btn btn-outline-danger" id="lkBtn">♡ <span id="lkCount">42</span></button>
<button class="btn btn-outline-primary" id="bmBtn">🔖 Save</button>
<small class="text-secondary ms-auto" id="lkMsg"></small>
</div></div>var lk=document.getElementById('lkBtn'),cnt=document.getElementById('lkCount'),liked=false,n=42;
lk.onclick=function(){liked=!liked;n+=liked?1:-1;cnt.textContent=n;lk.firstChild.textContent=liked?'♥ ':'♡ ';lk.classList.toggle('btn-danger',liked);lk.classList.toggle('text-white',liked);lk.classList.toggle('btn-outline-danger',!liked)};
document.getElementById('bmBtn').onclick=function(){this.classList.toggle('btn-primary');this.classList.toggle('text-white');document.getElementById('lkMsg').textContent='Saved!';};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.