问题描述
我将代码更改为与jQuery 1.8兼容,而且我坚持使用 hover
,这不起作用。当我对使用同样的东西时,点击
它就起作用了。这里是我的代码,任何人都可以告诉我哪里出错了?
$(document).on('hover','.top-level',function(event){
$(this).find('。actionfcnt')。show();
$(this).find('。dropfcnt')。show();
},function(){$隐藏('blind',function(){
$('。actionfcnt')。hide();
});
$(this).find('。dropfcnt')。 b $ b});
自jQuery 1.8弃用:名称hover用作字符串mouseenter mouseleave的简写。它为这两个事件附加一个事件处理程序,处理程序必须检查event.type以确定该事件是mouseenter还是mouseleave。 请勿将悬停伪事件名称与接受一个或两个函数的.hover()方法混淆。 来源: http://api.jquery.com/on/#additional-notes 几乎可以说这一切,你不能使用悬停为: I'm changing my codes to be compatible with jQuery 1.8 and I'm stuck with this Deprecated as of jQuery 1.8: The name "hover" used as a shorthand for the string "mouseenter mouseleave". It attaches a single event handler for those two events, and the handler must examine event.type to determine whether the event is mouseenter or mouseleave. Do not confuse the "hover" pseudo-event-name with the .hover() method, which accepts one or two functions. Source: http://api.jquery.com/on/#additional-notes That pretty much says it all, you cant use "hover" for that: 这篇关于jquery悬停无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
<$ p $ ('mouseenter','。top-level',function(event){
$(this).find('。actionfcnt')。show( );
$(this).find('。dropfcnt')。show();
})。on('mouseleave','。top-level',function(){$ b $隐藏('blind',function(){
$('。actionfcnt')。hide();
}); $ b $(this.find('。dropfcnt')。 b});
hover
which doesn't work. When I used then same thing with a click
it worked. Here is my code, can anyone tell me where I'm going wrong? $(document).on('hover', '.top-level', function (event) {
$(this).find('.actionfcnt').show();
$(this).find('.dropfcnt').show();
}, function () {
$(this).find('.dropfcnt').hide('blind', function () {
$('.actionfcnt').hide();
});
});
$(document).on('mouseenter','.top-level', function (event) {
$( this ).find('.actionfcnt').show();
$( this ).find('.dropfcnt').show();
}).on('mouseleave','.top-level', function(){
$( this ).find('.dropfcnt').hide('blind', function(){
$('.actionfcnt').hide();
});
});