我有兩個提交按鈕和一個表單。我如何檢查在我的jQuery代碼中選擇了哪個提交按鈕?如何處理一個表單上的兩個提交按鈕?
<% using (Html.BeginForm("UserInfo", "Home", FormMethod.Post, new { id = "formNext" })) { %>
....
<input id="submitHome" type="submit" name="goHome" value="Home" />
<input id="submitNext" type="submit" name="getNext" value="Next" />
<% } %>
$(document).ready(function() {
$('#formNext').submit(function() {
//Code Does not work but looking at something like this...
//$('#submitHome').click(function() {
// navigate to Home;
//});
//$('#submitNext').click(function() {
// return true;
//});
});
});
這是否老問題幫幫忙? http://stackoverflow.com/questions/2154039/jquery-submit-how-can-i-know-what-submit-button-was-pressed – Tobiasopdenbrouw 2010-07-23 19:18:01
你應該使用按鈕,而不是提交輸入。 – recursive 2010-07-23 19:33:46
爲什麼你刪除你的[最後一個問題](http://stackoverflow.com/questions/3366104/compatibility-view-kills-my-style-sheet-what-to-do)? – BalusC 2010-07-29 19:32:40