請看下面的代碼。IE中觸發的事件異步發生
var $myInput = $('#myInput'); //select the <input> element
$myInput.on('focus', function(){
console.log('Input focused');
})
現在如果我執行IE中的以下兩行:
$myInput.trigger('focus');
console.log('Done');
..輸出將是:
Done
Input Focused
這是因爲,在IE中,觸發事件執行異步。但這是所有其他瀏覽器的其他方式。是否有任何解決方法比使用triggerHandle()
或手動調用事件處理函數?
你的意思是這個訂單在其他瀏覽器中也不能保證? –
[如何訂購與jQuery綁定的事件]可能的重複(https://stackoverflow.com/questions/290254/how-to-order-events-bound-with-jquery) – Liam