[英]jQuery msgBox on Enter keypress
我有一个使用msgBox的usrID和PassWD,带有一个“登录”按钮。 我想将按钮单击功能与“ Enter”按键关联。 当按下Enter键时,其作用应与单击登录按钮时相同。
$.msgBox({
type: "prompt",
title: "Please Enter Your User Name & Password",
inputs: [
{header: "User Name*", type: "text", name: "userName", value: spl[0]},
{header: "Password*", type: "password", name: "password"}
],
buttons: [{value: "Login", type: "submit"}],
success: function(result, values) {
alert("Thanks...");
}
});
$(document).keypress(function(e) {
if(e.which == 13 && $("input[name='password']").val() != ""){
$("input[name='Concluir']").click();
}
});
我使用这段代码解决了这个问题。
以下应该工作:
$(document).keypress(function (e) {
if (e.which == 13 && $("input[name='password']").val() != "") {
$("input[name='Login']").click();
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.