我有一个表格,如果没有提交,那么它不应该显示表格#mytable 只有当表单被提交时才应该显示表格#mytable
我该怎么做?
<form action="" id="myform" method="get">
<strong>Søg på fritekst :</strong>
<input type="text" name="searchword" id="searchword" value=""/>
<input type="submit" id="show" value="Søg"/>
</form>
<table width="100%" id="mytable" class="sortable" border="0" cellpadding="2" cellspacing="2" style="border:1px solid #D4D4D4;">
<tr>
<th bgcolor="#313c95" width="100" style="color: #FFF; font-weight:bold; text-align: left;">EAK Kode:</th>
<th bgcolor="#313c95" width="350" style="color: #FFF; font-weight:bold; text-align: left;">Beskrivelse:</th>
<th style="display:none;"></th>
<th style="display:none;"></th>
<th style="display:none;"></th>
</tr>
</table>
最佳答案
确保你的 id 为 mytable
的表是隐藏的(使用 display: none
或类似的东西),然后使用这个 jQuery:
$('#myform').submit(function() {
$('#mytable').show();
return false;
});
请注意,这会阻止处理表单操作(即发布到您的服务器)。
关于javascript - 提交表单时显示表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3456991/