jQuery从点击更改为悬停

时间:2013-01-07 13:38:54

标签: jquery menu hover

我遇到了jQuery的问题。我使用函数.click创建了一个菜单,但是当我点击链接COLLECTIONS时,我需要在悬停菜单中对此菜单进行转换。

这是jQuery代码:

$(document).ready(function(){
  $("div#toggle a.button").click(function () {
    $("div#toggle div.box").toggle("slow");
});
hidden = true;
$("div#custom a.button").hover(function () {
  if(hidden == false) {
    $("div#custom div.box").fadeOut();
    hidden = true;
  } else {
    $("div#custom div.box").fadeIn(100);
    hidden = false;
  }
});

这是CSS代码:

#custom {
  z-index:0;
}

.box {
  width:100%;
  height:20px;
  border:0px solid #999;
  background-color:rgb(128, 129, 132);
  display:none;
  position:fixed;
  left:0;
  margin-top:6px;
  z-index:0;
  font-family:Arial, Helvetica, sans-serif;
  font-size: 10px;
  color:#E6E4D7;
}

页面位于http://www.mediaxsrl.it/web/loloey/forme/formeit.html

1 个答案:

答案 0 :(得分:0)

试试这个

$("#custom").hover(function() { 
    $(this).find("box").slideDown(); 
} , function() {  
    $(this).find("box").hide(); 
});
相关问题