Enter 按钮的行为与 MVC2 中的按钮单击不同
我有一个 MVC2 项目,其中有一个页面应该调用 jquery 函数。当您通过鼠标单击按钮时,我的 jquery 函数将被调用。当然,我的按钮 ID 上有一个 .click() 函数调用。我的猜测是,当我按 Enter 键时,我只是执行表单提交,而不是执行单击动作。有没有一种方法可以让回车按钮做与 .click() 相同的事情,或者至少使用 jquery 或任何事实上的东西来禁用回车按钮,以便用户无法按回车键并且将有通过鼠标按下?
任何想法将不胜感激。与此同时,我将继续在互联网上搜索,找出我能为此做些什么。
谢谢。
I have an MVC2 project that has a page on it that is supposed to call a jquery function. When you click on the button via the mouse my jquery function is called. I of course have a .click() function call on my button ID. My guess is that I am simply performing a form submit when I press enter instead of going through the click motion. Is there a way that I can either have the enter button do the same thing as the .click() or at least use jquery or anything as a matter of fact to disable the enter button so that a user can not hit enter and will have to press via the mouse?
Any ideas will be greatly appreciated. In the meantime, I will continue to scour the internet to figure out what I can do for this.
thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您应该能够挂钩表单 submit 事件:
使用它应该可以处理单击按钮或按 Enter 键。
I would think that you should be able to just hook into the forms submit event:
Using this should handle either the button click or an enter key press.
试试这个
该函数查找除 TextArea 之外的所有控件的 Enter 键按下并调用提交事件。
Try this
This function looks for enter key press for all controls except TextArea and calls a submit event.