开发者

jquery bind keyup to body in firefox

开发者 https://www.devze.com 2023-02-03 19:17 出处:网络
i m 开发者_如何学JAVAbinding keyup function in jquery to body which works in every browser except firefox

i m 开发者_如何学JAVAbinding keyup function in jquery to body which works in every browser except firefox

the code: -

 $('body').bind('keyup', function(e) {
    //alert ( e.which );
    alert('testing');

});

how do i do it for firefox. it does not responds at all

thanks


bind the event to the document instead:

$(document).bind('keyup', function(e) {
    alert('testing');
});

You can make almost any node receive keyboard events. In "modern" browsers, you can setup a tabIndex. After that the event is focusable.

$(document.body).attr('tabIndex', 1).bind('keyup', function(e) {
    alert('testing');
});
0

精彩评论

暂无评论...
验证码 换一张
取 消