经过一些测试后,我注意到这event.stopImmediatePropagation()
在 IE 中不起作用(按照下面的用法)。但是,它适用于 Chrome、Firefox、Safari 和 Opera。是什么赋予了?
请参阅此小提琴以在 IE 中重现(在其他浏览器中测试小提琴以使其正常工作)。
小提琴Javascript:
$(function(){
$('#text').focus(function(event){
$('#text').val('Use the button to test this.');
});
$('#button').click(function(event){
// remove all handlers
$('#text').off('focus');
// now add this other handler in first position
$('#text').one('focus', function(event){
$('#text').val('Yay it works! stopImmediatePropagation works in your browser!!');
event.stopImmediatePropagation();
});
// now add a handler in the 2nd position that shouldn't get run
$('#text').focus(function(event){
$('#text').val('Oh No! stopImmediatePropagation failed to work in your browser!!');
});
// now set the focus to test it
$('#text').focus();
});
});
小提琴html:
<input id='button' type="button" value="Start Test"/>
<input id='text' style='width:400px;' />