現在我有這樣的代碼:變化格顏色 - jQuery函數
$('.a').mouseenter(function(){
var $this = $(this);
clearTimeout($this.data('timerMouseleave'));
$this.css('border', 'solid 1px #444444')
}).mouseleave(function(){
var $this = $(this);
var timer = setTimeout($.proxy(function(){
$this.css('border', 'solid 1px #dddddd')
}, this), 1000)
$this.data('timerMouseleave', timer)
}).click(function(){
var $this = $(this);
$this.css('border', 'solid 1px black')
$this.off('mouseenter mouseleave');
})
我要再次添加紅色邊框僅在進入格的情況下,而超時仍然在。 (如果可能的話,請在這種情況下播放聲音,例如aaa.wav)。
我需要保持這種行爲的其餘部分完全如此,這意味着紅色邊框通常應該在超時後變回默認值。
澄清:
超時/延遲被鼠標離開後觸發,並持續1秒鐘。
- 目前的情況:如果你進入前再次1秒到期的股利,超時被刪除,然後又鼠標離開
- 想情況後,再次觸發:如果你進入前再次1秒到期的股利,邊界變得紅,超時被刪除,然後又鼠標離開
請詳細說明您的問題..很難理解您真正想要什麼。 – Sid
哪個紅色邊框?我的代碼中沒有看到任何紅色。 – Rob
完成後,從'.data()'中移除'timerMouseleave'。這樣,如果'timerMouseleave'存在於元素的'.data()'中,則意味着超時不是由於它。 (我希望我能正確理解你的問題) – naor