[英]jQuery forward slash from button click
我试图这样做,当我点击一个按钮输入一个键,我试图让/
键工作。 目前其代码值(191)正在进入¿ 有任何想法吗?
$("button").click(function() {
$("input").focus();
var e = jQuery.Event("keydown");
e.which = 191; // # Some key code value
$("input").val(String.fromCharCode(e.which));
$("input").trigger(e);
});
$('input').keydown(function(e){
console.log('Yes keydown triggered. ' + e.which)
});
HTML:
<input type="text">
<button>button</button>
http://jsfiddle.net/scottux/83GTf/
$("button").click(function() {
$("input").focus();
var e = jQuery.Event("keydown");
e.which = 47; // # Some key code value
$("input").val(String.fromCharCode(e.which));
$("input").trigger(e);
});
$('input').keypress(function(e){
console.log('Yes keydown triggered. ' + e.which)
});
按键事件使用正确的密钥代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.