最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery dropdown plugin - How to know if dropdown is open or not? - Stack Overflow

programmeradmin0浏览0评论

I am using this plugin for jQuery: /

I want to do something when hovering a div element IF dropdown is currently open, or something else if dropdown is currently closed while hovering the div element.

Psuedo code:

$('#foo').hover(function() {
    if ( $('*').dropdown('is_visible') ) {
        alert('Dropdown is visible, so do something...');
    }
    else {
        alert('Dropdown is NOT visible, so do something else...');
    }
});

Can anyone see how this can be acheived with this plugin? Can I search the DOM for some class or something?

Thanks in advance!!

I am using this plugin for jQuery: http://labs.abeautifulsite/jquery-dropdown/

I want to do something when hovering a div element IF dropdown is currently open, or something else if dropdown is currently closed while hovering the div element.

Psuedo code:

$('#foo').hover(function() {
    if ( $('*').dropdown('is_visible') ) {
        alert('Dropdown is visible, so do something...');
    }
    else {
        alert('Dropdown is NOT visible, so do something else...');
    }
});

Can anyone see how this can be acheived with this plugin? Can I search the DOM for some class or something?

Thanks in advance!!

Share Improve this question asked Jul 17, 2014 at 3:42 NickNick 1432 silver badges10 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

You can seek class "dropdown-open". Might be:

if ($(".dropdown-open").length > 0) {
 // A dropdown is opened
} else {
 // No opening dropdown
}

The plugin uses a unique id for each dropdown, i.e., dropdown-1, dropdown-2, dropdown-3, etc.

You may use this id to target a specific dropdown. Check wether its css display is block or none.

发布评论

评论列表(0)

  1. 暂无评论