2015-06-15 44 views
1

我想打开一个下拉悬停在Bootstrap,但不知何故,它不工作。我怀疑我的jQuery代码是错误的,但我无法弄清楚什么?悬停下拉不起作用,我做错了什么?

这里是我的HTML:

<a href="#" id="dropdown-filter" data-target="#" data-toggle="dropdown"> 
    <button type="button" class="btn btn-primary">Filters</button> 
</a> 
<ul class="dropdown-menu pull-right" role="menu"> 
    <li> 
     <div class="results-filter"> 
      Content goes here 
     </div> 
    </li> 
</ul> 

和我的jQuery:

jQuery('#dropdown-filter').hover(function() { 
    jQuery(this).find('.dropdown-menu').stop(true, true).delay(100).fadeIn(); 
}, function() { 
    jQuery(this).find('.dropdown-menu').stop(true, true).delay(100).fadeOut(); 
}); 

它当我点击顶部,而不是当我将鼠标悬停工作。

回答

4

jQuery(this).find('.dropdown-menu')在这里不起作用.dropdown-menu不是<a>-#dropdown-filter的子女。

.find()搜索儿童。

使用jQuery(this).next('.dropdown-menu')...

+0

啊,我知道了!谢谢 :) – user1227914

相关问题