admin管理员组

文章数量:1415111

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.

本文标签: javascriptjQuery dropdown pluginHow to know if dropdown is open or notStack Overflow