D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
hkjels
Full window
Github gist
Inbox count
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Inbox count</title> <link rel="stylesheet" href="badge.css"> </head> <body> <ul class="menu"> <li class="menu-item"> <a class="fill badge" href="/#" data-count="69">Inbox</a> </li> </ul> <script> var btn = document.querySelector('a'); function increment(){ btn.classList.add('inc'); setTimeout(function(){ btn.classList.remove('inc') }, 500); btn.dataset.count = parseInt(btn.dataset.count) + 1; setTimeout(increment, Math.floor((Math.random() * 10000) + 1)); } increment(); </script> </body> </html>