我創建了3個使用輸入類型按鈕顯示的div,這些按鈕用於顯示和隱藏最初隱藏的div。在這些div中有用於存儲數據的表單。現在我想要做的是在提交表單中的數據後保留當前使用的div。
在表單提交後保留顯示的div
這是我的jQuery代碼。
$("#add_exams").hide();
$("#exams").hide();
$("#add_accts").hide();
$("#view_exam").click(function(){
$("#add_exams").hide();
$("#exams").hide();
$("#add_accts").hide();
$("#exams").fadeIn();
});
$("#create_exam").click(function(){
$("#add_exams").hide();
$("#exams").hide();
$("#add_accts").hide();
$("#add_exams").fadeIn();
});
$("#manage_accts").click(function(){
$("#add_exams").hide();
$("#exams").hide();
$("#add_accts").hide();
$("#add_accts").fadeIn();
});
//$(document).on("click", "#selectall",function(){
$(document).on("submit","#submit_acct", function(){
$("#add_accts").fadeIn();
});
我的HTML是這樣
<div id="content">
<input type="button" id="create_exam" value="Create Exam" title="Click to create new exam." />
<input type="button" id="view_exam" value="Exam" title="Click to view exam." />
<input type="button" id="manage_accts" value="Accounts" title="Click to view exam." />
<div id="add_accts">
/*forms goes here */
</div>
<div id="add_exams">
/*forms goes here */
</div>
<div id="exams">
/*forms goes here */
</div>
</div>
當我嘗試提交數據,股利不顯示,我試圖用一個jQuery將顯示我想要的股利,但它不工作,所有這些都是隱藏的。我只需要保留以顯示當前顯示的div,對此的任何想法?
嘗試添加event.preventDefault();到您的提交js並做了阿賈克斯之後 – Roi 2014-09-22 08:15:15
我想你已經錯過了一些東西 – Mayank 2014-09-22 08:54:40