var $li = $('#menu li').click(function() {
$li.removeClass('selected');
$(this).addClass('selected');
});
li.selected {
color: green;
}
const $li = document.querySelectorAll('#menu li');
$li.forEach(elem => {
elem.addEventListener('click', function () {
$li.forEach(el => el.classList.remove('selected'));
this.classList.add('selected');
});
});