jq設定action並且提交
阿新 • • 發佈:2018-12-30
<script src="js/jquery.min.js"></script>
<script>
//點選表單“提交”按鈕
$(function login(){
$("#login").bind("click", function () {
var url = "${pageContext.request.contextPath}/checkLogin.action";
//更改form的action
$("#lginAndregist").attr("action", url);
//觸發submit事件,提交表單
$("#lginAndregist").submit();
});
});
</script>
<form action="" method="post" id="lginAndregist" name="lginAndregist">
<input type="text" name="userName" class="userName" placeholder="userName">
<input type="password" name="userPassword" class="userPassword" placeholder="userPassword">
<button id="login" onclick="login()">登入</button>
<button id="regist" onclick="regist()">註冊</button>
<div class="error"><span>+</span></div>
</form >