所以我試圖提交一個表單在jquery隱藏或顯示的東西。Jquery:表單提交不正常
但是在再次提交後它不起作用。
HTML:
<form id="filters" href="#">
<table id="filter" class="table">
<thead>
<tr>
<th>Show/Hide</th><th>Column</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input type="checkbox" name="checkNumber" value="1"/>
</td>
<td>
Account Number
</td>
</tr>
</tbody>
</table>
</form>
的Jquery:
$(function() {
$('#filters').submit(function() {
if ($('input[name=checkNumber]').attr('checked') == true) {
$('input[name=search_account]').show("normal");
}
else if ($('input[name=checkNumber]').attr('checked') !== true) {
$('input[name=search_account]').hide("normal");
}
return false;
});
});
我試過很多其他方法,但它所有的工作原理相同。我提交,它隱藏了正確的輸入標籤,但是當我重新提交以顯示它時,它不起作用。
如果我通過選中複選框提交它也不起作用。
任何幫助將不勝感激!
你還是試試'else',而不是'其他if'。 –
再次看看你的代碼 - 你到底想要達到什麼目的?表單提交後,它將重新加載頁面,不是嗎? –
不,它不重新加載頁面,它只是提交jquery來執行。 – designtocode