$(document).keypress(function(event) {
// +
if (event.which == 43) {
// ...
}
}
HTML
<input type="button" value="+" name="plus">
单击按钮时如何使用 + 触发按键方法?
$('input[name="plus"]').click(function(){
// ??? How to go further ???
})
答案 0 :(得分:7)
你去吧
var e = jQuery.Event("keypress");
e.which = 43; // # Some key code value
$(document).trigger(e);
答案 1 :(得分:1)
$(document).on('keypress',function(e) {
if (e.keyCode == 43 || e.which == 43) {
var identifier = e.target.id;
console.log(e.target.id);
$('#' + identifier).click();
}
});