var current = null; document.body.addEventListener('click', function(ev) { if (ev.target.tagName === 'BUTTON') { if (current) { current.classList.remove('focus'); } current = ev.target; current.classList.add('focus'); } }, false);
button { display: block; } .focus { background: red; }
<button>Click me</button> <button>No, me</button> <button>Seriously, I click much better</button> <button>Don't listen to that guy</button> <button>I clicked before it was cool</button> <button>Don't click me</button>