我正在尝试按下小键盘6
并触发按comma
键。
我尝试过但不起作用。
<input name="text" value="" />
<script type="javascript/text">
$(function() {
$("input").keypress(function (e) {
if (e.which == 102) { //numpad 6
e = jQuery.Event("keydown"); // define this once in global scope
e.which = 188; // Comma
$(this).trigger(e);
}
});
});
</script>
我如何解决?我想要的结果是按下小键盘6
,而不是出现在输入中的6 comma
。
答案 0 :(得分:0)
也许你想像这样做smt
$(function() {
$("input").keypress(function (e) {
if (e.which == 102) {
e.preventDefault();
$(this).val(e.currentTarget.value + ',')
}
});
});