簡體   English   中英

懸停時的Bootstrap下拉菜單不起作用,我在做什么錯?

[英]Bootstrap dropdown on hover not working, what am I doing wrong?

我正在嘗試在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();
});

當我單擊頂部時,它起作用,但是當我懸停時,它不起作用。

jQuery(this).find('.dropdown-menu')在這里不起作用,因為.dropdown-menu不是<a>-#dropdown-filter

.find()搜索子級。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM