I'm facing difficulty with this task - when hovering over elements, an active class should be added to them. However, when moving the mouse to another section, the active class should remain on the last element hovered. Additionally, the first block should have the active class by default.
<div class="work-elem">
<div class="work-elem">
<div class="work-elem">
<div class="work-elem">
$(".work-elem:first").addClass("active");
$(".work-elem").each(function() {
$(".work-elem").hover(function() {
$(this).removeClass("active");
$(this).addClass("active");
},
function() {
$(this).removeClass("active");
});
});