It’s called “event bubbling” or “event propagation” and the solution is to get the event object and use the JS stopPropagation
method. Try this:
jQuery('.menu-item').click(function(event){
var class_id = jQuery(this).attr('id');
event.stopPropagation();
alert(class_id);
});