答案 0 :(得分:0)
您可以使用.mouseover()和.mouseout()来实现相同的效果。如果你想延迟动画,你可以在jQuery UI中使用.animate()
$('#sample').mouseover(
function() {
$(this).stop().animate({
backgroundColor: "yellow"}, 200);
});
$('#sample').mouseout(
function() {
$(this).stop().animate({
backgroundColor: "#aaa"}, 200);
});
答案 1 :(得分:0)
从jQuery 1.9.1开始,其他浏览器已经赶上了Opera - 它现在不再适用于它。正如你的小提琴所调查的那样,“它”是.is(“:悬停”)。
我为.is(“:hover”)写了一个解决方法,请参阅小提琴http://jsfiddle.net/mathheadinclouds/BxL4w/
function mouseIsOver(what){
return $(what).is(":hover");
}
function mouseIsOverWorkaround(what){
var temp = $(what).parent().find(":hover");
return temp.length == 1 && temp[0] == what;
}
function mo(what){
return document.getElementById("workaround").checked ? mouseIsOverWorkaround(what) : mouseIsOver(what);
}
setInterval(function(){
var theBox = $("#theBox");
if(mo(theBox[0])) {
theBox.css("background", "yellow");
} else {
theBox.css("background", "");
}
}, 200);
和html
<input type="checkbox" id="workaround"/>
<div id="theBox"></div>