The
.hover() method can take two parameters of function type — the first one is intended for the mouseenter event handler and the second one — for the mouseleave event handler.
If you pass a single function as a parameter of the .hover() method, it will be executed for both mouseenter and mouseleave events.
So, try to change your code in the following way:
Code:
$(document).ready(function() {
$('#headerLinks ul li a').hover(
function() { alert('hello!'); },
function() { /* do nothing */ }
);
});
Alternatively, you can simply use the
.mouseenter() method to bind you handler to the target elements.