knikolov
knikolov

Reputation: 1800

JQuery: mouseout event triggering

I am trying to simulate event handling on mouseout using jQuery, however the event handler is not invoked in the test environment. What might be the cause?

Upvotes: 2

Views: 633

Answers (2)

adeneo
adeneo

Reputation: 318342

Something like this ?

$(document).ready(function() {
    $('#test, .comments').on('mouseenter', function() {
        $('.comments').stop(true,true).show('slow');
    });
    $('#test').on('mouseleave', function() {
        $('.comments').stop(true,true).hide('slow');
    });
})​;​

FIDDLE

Could also be shortened to just:

$('#test').on('mouseenter mouseleave', function(e) {
    $('.comments').stop(true,true)[e.type==='mouseenter'?'show':'hide']('slow');
});

FIDDLE

Upvotes: 1

SharkyLV
SharkyLV

Reputation: 329

I think you are looking for mouseenter and mouseleave.

They execute only once on hover and on out.

http://api.jquery.com/mouseenter/

http://api.jquery.com/mouseleave/

Upvotes: 0

Related Questions