我有一个jQuery消息框要获取我们的ID&PassWD带有"登录"按钮。我想把按钮点击功能和"回车"键联系起来。当按下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();
}
});