<script>
document.addEventListener('DOMContentLoaded', function () {
const menuItems = document.querySelectorAll('.headmenu li');
menuItems.forEach(function (menuItem) {
menuItem.addEventListener('click', function () {
menuItems.forEach(function (item) {
item.classList.remove('selectedclass');
});
this.classList.add('selectedclass');
});
});
});
</script>
Can you provide an alternative JavaScript code for the jQuery function above?