可以在将值添加到输入文本框后对“输入”进行编程吗?
如果是,我需要以下代码的帮助。它不会触发“ENTER”按键。
我的代码如下:
$('#clo_cart').click( function () {
/*Save ENTER in variable*/
var eneterKey = jQuery.Event("keydown");
eneterKey.which = 13;
eneterKey.keycode = 13;
$("#scan_char").focus().val('CLOSECTN').trigger(eneterKey);
}//end of button click
请帮助
答案 0 :(得分:0)
只需将handlers:
# Serve images and JSON as static resources.
- url: /(.+\.(gif|png|jpg|json|ico))$
static_files: \1
upload: .+\.(gif|png|jpg|json|ico)$
application_readable: true
- url: \/(static)\/(index)\.html
static_files: static/\1/index.html
upload: static\/index.html
- url: /
script: roomusage.app
login: required
secure: always
- url: /welcome
script: roomusage.app
login: required
secure: always
- url: /record
script: record_usage.app
login: required
secure: always
事件替换为appcfg.py: error: Error parsing C:\gcloud\dev-myapp\app.yaml: Unable to assign value '\/(static)\/(index)\.html' to attribute 'url':
Value '\/(static)\/(index)\.html' for url does not match expression '^(?:(?!\^)/.*|\..*|(\(.).*(?!\$).)$'
in "C:\gcloud\dev-myapp\app.yaml", line 25, column 8.
2017-12-08 09:27:50 (Process exited with code 2)
事件即可。他们使用keydown
属性的方式有所不同。这可能是其中两个使用keypress
的不同值的情况之一。
event.which
另请注意,event.which
属性已被弃用。您可以与var eneterKey = jQuery.Event("keypress");
属性进行比较。当要模拟回车键时,它应该具有值which
。
event.key
答案 1 :(得分:0)
以下代码对我来说很好。
$('#clo_cart').click( function () {
$("#scan_char").focus().val('CLOSECTN').trigger(enterKey());
}//end of button click
/* Function to allow program keypress ENTER */
function enterKey() {
return $.Event( "keypress", { which: 13 } );
}
答案 2 :(得分:0)
您可以使用此代码
$('#clo_cart').click( function () {
var e = $.Event( "keypress", { which: 13 } );
$("#scan_char").focus().val('CLOSECTN').trigger(e);
}//end of bu