Reputation: 1800
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
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');
});
});
Could also be shortened to just:
$('#test').on('mouseenter mouseleave', function(e) {
$('.comments').stop(true,true)[e.type==='mouseenter'?'show':'hide']('slow');
});
Upvotes: 1
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