My website has a specific set of <p class="first">
elements that change background color on hover using CSS.
<div id="row_1">
<p class="first">first_1</p>
<p class="first">first_2</p>
<p class="first">first_3</p>
<p class="first">first_4</p>
<p class="first">first_5</p>
</div>
This is achieved with the following CSS:
.first:hover {
background-color: #ddd;
}
In addition to this, I have implemented a jQuery function to handle click events for each .first
element, changing the background colors accordingly:
$('.first').click(function() {
$(this).css('background-color', '#ddd');
$('.first').not(this).css('background-color', 'blue');
});
However, I have noticed that after the jQuery function runs, the :hover
effect stops working. Why does this happen? Does changing the background color override the hover effect?