var $list = document.querySelector('ul') var $items = [].slice.call(document.querySelectorAll('li')) for (var i = 0, l = $items.length; i < l; i++) { var $item = $items[i] $item.addEventListener('click', event => $list.className = event.currentTarget.className) }