Zsolt Janes Zsolt Janes - 7 months ago 32
jQuery Question

jQuery function display 2 times

I have the following jQuery function but i dont know why is it display again after i waived the hover. The concept is, if the class is exist remove them after that load the new menu (from 1.php), wait 1000 and add new classes. Its working fine, but after i move my mouse to other dierction the concept run again. Why?

$(document).ready(function () {
$("#cikkek").hover(function () {
setTimeout(function () {
}, 1000);


jQuery hover binds 2 events, mouseenter and mouseleave so it will fire twice.

You can either have an empty mouseleave function or rather than using hover change it to mouseenter

$("div").mouseenter(function() {
     $(this).css("background-color", "blue");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>

  Enter your mouse here