经过一些测试后,我注意到event.stopImmediatePropagation()在IE中不起作用(下面的每个用法)。但是,它适用于Chrome,FF,Safari和Opera。是什么赋予了?为什么event.stopImmediatePropagation()可以在除IE以外的所有浏览器中工作?
请参阅this fiddle重新在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;' />
不确定,而且我没有简单的IE访问测试。这可能会有所帮助:http://stackoverflow.com/questions/6446482/how-can-i-mimic-the-behaviour-of-stopimmediatepropagation-without-using-jquer – 2013-03-12 01:40:58