jQuery mouseenter事件未在鼠标中触发,单击
时触发它function showOverlap() {
var hits = $('.follower').collision('#slides li');
$(hits).trigger('mouseenter');
}
$('.container1').mouseenter(function() {
showOverlap();
});
$('#slides li').on('mouseenter',function(){
$('#slides li').removeClass('selectedMenu');
$(this).addClass('selectedMenu');
});
JsBin http://jsbin.com/urEpESAM/19/edit
如果在mouseMove中写入mouseenter事件但是速度慢得多
,这里工作正常答案 0 :(得分:1)
试试这个
$(document).on({
mouseenter: function() {
$('#slides li').removeClass('selectedMenu');
$(this).addClass('selectedMenu');
},
mouseleave: function() {
// Do stuff when mouse leaves `#slides li`
}
}, "#slides li");
答案 1 :(得分:0)
如果要触发mouseenter事件,则需要绑定该事件。你的问题不是mouseenter。
看看这里:http://jsfiddle.net/stryd3r/mA3wy/
您的问题排在第:$(hits).trigger('mouseenter');
答案 2 :(得分:0)
这应该可以解决问题:
function showOverlap() {
var hits = $('.follower').collision('#slides li');
$(hits).trigger('mouseenter');
}
$('.container1').mouseenter(function() {
showOverlap();
});
$(this).bind('mouseenter',function(){
alert("in");
$('#slides li').removeClass('selectedMenu');
$(this).addClass('selectedMenu');
});