我有一个按钮,点击该按钮后,我有一个div要显示和隐藏。我使用jQuery实现了这一点。但问题是当页面加载时,div已经显示出来了。我希望只有在单击按钮时才能看到div。
这是我的代码:
脚本:
这是我的代码:
脚本:
<script>
$(document).ready(function() {
$('#btn').live('click', function(event) {
$('#div1').toggle('show');
});
});
</script>
HTML:
<input type="button" id="btn" class="btncss" value="filter" />
<div id="div1" runat="server" style="height:300px;width:300px;background-color:#f3fbd6">
<table>
<tr>
<td>
<asp:TextBox ID="txt" runat="server" TextMode="MultiLine"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:DropDownList ID="ddl" runat="server"></asp:DropDownList>
</td>
</tr>
</table>
<hr />
<table>
<tr>
<td>
<asp:Button ID="btncancel" runat="server" Text="cancel" />
</td>
<td>
<asp:Button ID="btnFilter" runat="server" CssClass="btncss" Text="Filter" />
</td>
</tr>
</table>
</div>
div1
,因此它将无法工作。 - Satpallive()
代码对我有效。 - Dinav Ahire