0
可能重复:
Javascript onkeypress如何添加JavaScript函数文本框控件在onkeypress事件
我有很多网页在我的网站。 (使用dot.net)
我已经写了一个onKeypress事件函数在JavaScript中,应该由我的所有文本框(总站点)使用。
我该如何做到这一点?
可能重复:
Javascript onkeypress如何添加JavaScript函数文本框控件在onkeypress事件
我有很多网页在我的网站。 (使用dot.net)
我已经写了一个onKeypress事件函数在JavaScript中,应该由我的所有文本框(总站点)使用。
我该如何做到这一点?
您正在寻找一个keydown事件。 这里的可用库GitHub上
https://github.com/jeresig/jquery.hotkeys
$(expression).bind(types, keys, handler);
$(expression).unbind(types, handler);
$(document).bind('keydown', 'ctrl+a', fn);
// e.g. replace '$' sign with 'EUR'
$('input.foo').bind('keyup', '$', function(){
this.value = this.value.replace('$', 'EUR');
});
更努力。这个网站已经有很多答案。 – 2012-03-29 13:56:59