jQuery:如何触发悬停?

Ale*_*x G 5 jquery

如何触发第二个悬停功能?

$('#adm1n-toolbar').hover(
    function() {
        ...
    },
    function() {
        ...
    }
);

$('#adm1n-toolbar-content select').change(function(e) {
    ...
    $('#adm1n-toolbar').trigger('mouseout');
});
Run Code Online (Sandbox Code Playgroud)

mouseout或mouseleave不起作用.

Gab*_*oli 10

如果您使用幕后使用的功能mouseleave,它可以正常工作hover

http://jsfiddle.net/gaby/6fyeS/上的演示


Ror*_*san 8

您无法在外部定位第二个函数hover().但是,hover()这只是一个快捷方式mouseenter(),mouseleave()您可以单独分配它们,以便根据需要触发它们.试试这个:

$('#adm1n-toolbar')
    .mouseenter(function() {
        // ...
    })
    .mouseleave(function() {
        // ...
    });

$('#adm1n-toolbar-content select').change(function(e) {
    $('#adm1n-toolbar').trigger('mouseleave');
});
Run Code Online (Sandbox Code Playgroud)