开发者

Why jQuery hover gets stuck sometimes and how to fix it?

开发者 https://www.devze.com 2023-01-18 13:33 出处:网络
Sometimes when I hover on the elements the dropdown sucks and works vice versa, mostly when I\'m already on the element and when the page starts to load, so you should test it with some reloads.

Sometimes when I hover on the elements the dropdown sucks and works vice versa, mostly when I'm already on the element and when the page starts to load, so you should test it with some reloads.

Check out : Live Preview

Video Screencast : Video Screencast Link

The jQuery:

  $(function() {
    $("ul > li").hover(function() {
      $(开发者_如何转开发this).find("ul").stop(true, true).fadeIn('fast');
    }, function() {
      $(this).find("ul").stop(true, true).fadeOut('fast');
    });
  });

This snippet finds all ul's and fades in or out the ul's what inside of the parent ul.


It seems to work fine. There is an appearance of the drop down getting stuck if you move your mouse horizontally. This is because the width of the li tag spans the whole window. Maybe you just need to set a shorter width.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号