经过一些测试,我注意到,event.stopImmediatePropagation()在IE(低于每使用)不起作用。 然而,它的工作原理在Chrome中,FF,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;' />