mr_*_*app 1 javascript firefox jquery google-chrome keypress
我有一个问题,在chrome和IE上获取事件"keypress".在Firefox上它运作良好.
function bind_input_keypress ($this) {
$($this).bind('input', function() {
$($this).css('width',$($this).val().length*5.5+20);
})
$($this).bind('keypress',function(e) {
/* delete last extra... */
if( e.keyCode == '8' && $($this).val()=='' ) { $('#extras b').remove(); }
/* arrow up */
if( e.keyCode == '38' ) {
console.log('38 pressed');
}
/* arrow down */
if( e.keyCode == '40' ) {
console.log('40 pressed');
ad_curr = $('.ad_selectbox .autocomplete ul li.active');
}
});
}
$('input').focus(function(){
bind_input_keypress($(this));
})
Run Code Online (Sandbox Code Playgroud)
为什么这不适用于chrome和IE?
你也可以在jsfiddle上查一下 http://jsfiddle.net/a5M6S/2/
| 归档时间: |
|
| 查看次数: |
811 次 |
| 最近记录: |