【发布时间】:2012-07-23 09:16:40
【问题描述】:
我正在尝试使用 jQuery 模拟 mouseout 上的事件处理,但是在测试环境中未调用事件处理程序。可能是什么原因?
【问题讨论】:
-
将您的代码发布到jsfiddle.net。我想解决你的问题:)
我正在尝试使用 jQuery 模拟 mouseout 上的事件处理,但是在测试环境中未调用事件处理程序。可能是什么原因?
【问题讨论】:
这样的?
$(document).ready(function() {
$('#test, .comments').on('mouseenter', function() {
$('.comments').stop(true,true).show('slow');
});
$('#test').on('mouseleave', function() {
$('.comments').stop(true,true).hide('slow');
});
});
也可以简写为:
$('#test').on('mouseenter mouseleave', function(e) {
$('.comments').stop(true,true)[e.type==='mouseenter'?'show':'hide']('slow');
});
【讨论】:
【讨论】: