table.onclick = function(event) { var target = event.target; while (target != table) { if (target.classList.contains('class')) { highlight(target); return; } } };