我有一个ASP.NET MVC 3 C#.NET的Web应用程序,我想让Enter键触发表单中特定的保存按钮。我该如何实现?
我有一个ASP.NET MVC 3 C#.NET的Web应用程序,我想让Enter键触发表单中特定的保存按钮。我该如何实现?
onkeypress
事件中进行处理,代码如下:<form onkeypress="yourKeyPressFunction(event)">
...
</form>
那么你的 yourKeyPressFunction()
函数看起来会像这样:
function yourKeyPressFunction(e)
{
if (e.keyCode == 13)
{
// submit or do what you'd like when you hit enter
}
// ... so on and so forth
}