当我将鼠标悬停在按钮上时保留另一个div显示块,但如果我要翻转它则关闭块元素

时间:2013-07-15 22:39:52

标签: jquery mouseevent mouseleave

如何解决这个问题会有什么想法。基本上它与子菜单的想法相同。

 $(".button").on({
    mouseenter: function (e) {
       //display my other div as a block element and fade it in
    },
    mouseleave: function () {
 //if my mouse leaves that block element then fade it out.
 }
});

1 个答案:

答案 0 :(得分:0)

将CSS中的另一个div设置为display: none,然后使用jQuery的fadeIn()fadeOut()方法将其打开/关闭:

$(".button").on({
  mouseenter: function (e) {
    $(".other-div").fadeIn();
  },
  mouseleave: function () {
    $(".other-div").fadeOut();
  }
});

请参阅DEMO