<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<style type="text/css">
.active {
background-color: #aaaaaa;
}
</style>
<script>
$(document).ready(function() {
$menuItem = $('#menu').children('.item');
$menuItem.each(function() {
$(this).click(onClickMenuItem);
});
});
onClickMenuItem = function() {
$('#menu').children('.item').filter('.active').removeClass('active');
$(this).addClass('active');
}
</script>
</head>
<body>
<div id="menu">
<a class="item active">menu 1</a>
<a class="item">menu 2</a>
<a class="item">menu 3</a>
</div>
</body>
</html>