JQuery 模拟在输入字段中输入
我有一个表格,我用 Greymonkey 在其中输入信息。 表单没有 ID 或类...
当您手动在输入框中输入一些内容,然后按 Enter 键时,它就会被提交,然后您就可以离开...我想用 jquery 实现同样的效果。
更改输入 boc 的值不是问题,而是提交。
我有以下代码;
e = jQuery.Event("keypress");
e.which = 13;
e.keyCode = 13;
$("#inputy").focus();
$("#inputy").trigger(e);
但这不起作用...那么我如何用 ID inputy 模拟输入框的输入呢?
格瑞兹 TWCRAP
I've got a form, where i put information in with greasemonkey.
The form got no ID or Class...
When you manauly put something in the inputbox, and press enter, it get's submitted and you're off... I want to achief the same with jquery.
Changing the value's of the input boc is not the problem, but submitting.
Ive got the following code;
e = jQuery.Event("keypress");
e.which = 13;
e.keyCode = 13;
$("#inputy").focus();
$("#inputy").trigger(e);
But this doesn't work... So how does i simulate an enter in the inputbox with the ID inputy?
Greetz
TWCrap
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
那么您想提交表格吗?您可以尝试:
在每次按键时,我们都会检查
Enter
键。如果Enter
键被释放,我们就会找到最接近的表单并提交它。So you want to submit the form? You can try:
On every key-up we check for the
Enter
key. If theEnter
key was released we then find the closest form and submit it.可能按
上的 Enter 键会在整个
无论如何,该网站上肯定有
jquery
吗?控制台上有任何错误吗?Probably pressing enter on
<input>
firesubmit()
method on entire<form>
so try do it after you fill up your<input>
using following method:$("form").submit()
.Anyway, is there
jquery
for sure on that site? Are there any errors on console?