2

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;' />
4

1 に答える 1

3

IE は IE 9 ( http://msdn.microsoft.com/en-us/library/ie/ff975461(v=vs.85).aspx ) から stopImmediatePropgation をサポートしていますが、jquery が問題です。

コードで使用されている jquery バージョンが機能していません。このjsfiddleは IE で完全に動作し、コードはまったく同じです。唯一の違いは、jQuery 1.8.3 の代わりに jQuery 1.9.1 を使用することです。

于 2013-03-12T01:50:35.920 に答える