我:
<img id="leftBubble" class="bubbles" src="left.png" />
<img id="rightBubble" class="bubbles" src="right.png" />
而且悬停事件,像这样:
$(".bubbles").each(function(){
$(this).hover(function() {
pause($(this));
}, function() {
play(4000, $(this));
});
});
我暂停()函数似乎并不奏效
function pause(pauseMe) {
if (pauseMe == $("#leftBubble")) {
clearTimeout(timer1); //this is never reached
} else if (pauseMe == $("#rightBubble")) {
clearTimeout(timer2); //nor this
}
}
任何想让悬停事件传递$ this作为暂停函数的参数?
jQuery的平等最好用'。是( “选择”)'完成:看http://stackoverflow.com/questions/2448291/how-to-check-for-dom-equality-with-jquery/2448362#2448362 – 2012-04-17 20:41:55
比较jquery对象:http://stackoverflow.com/questions/2436966/how-would-you-compare-jquery-objects – malletjo 2012-04-17 20:42:47