我:
<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