jQuery 1.8:不支持的伪:悬停 [英] jQuery 1.8: unsupported pseudo: hover
问题描述
以下代码在jQuery 1.8上引发错误 unsupported pseudo:hover
,而它在jQuery 1.7.2上运行完美:
The following code raises the error unsupported pseudo: hover
on jQuery 1.8, while it works perfect on jQuery 1.7.2:
if(!$(this).parent().find('ul').first().is(':hover')) {
$(this).parent().parent().removeClass('open');
}
有谁知道发生了什么事?
Does anyone know what's going on?
推荐答案
不幸的是,虽然我们都希望我们的代码是未来的证明,但你的 $('foo')。on('hover,.. .function(){// do stuff}
代码在jQuery 1.8中弃用。我希望我有更好的消息,但你的代码因jQuery 1.8的核心变化而被破坏。你现在必须使用语法
Unfortunately, while we all wish that our code were future proof, your $('foo').on( 'hover, ... function(){ //do stuff }
code is deprecated in jQuery 1.8. I wish I had better news for you, but your code is broken because of a core change to jQuery 1.8. You now have to use the syntax
$('.selector').on( 'mouseenter mouseleave', function() {
$(this).toggleClass('hover');
}
);
if(!$(this).parent().find('ul').first().hasClass('hover')) {
$(this).parent().parent().removeClass('open');
}
希望我有更好的消息,但弃用发生:/ ... jQuery 1.8不喜欢你的快捷方式,他们已弃用 hover
事件处理程序从 .on()
以及伪选择器:hover
,所以它不能以任何方式使用更多。
Wish I had better news for you, but deprecation happens :/ ... jQuery 1.8 doesn't like your shortcut and they've deprecated the hover
event handler from .on()
and also the pseudo-selector :hover
, so it can't be used that way any more.
这篇关于jQuery 1.8:不支持的伪:悬停的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!