這是我的代碼:JQuery:如何在文本框不在焦點時隱藏DIV?
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtInsertComments" CssClass="expanding" runat="server" AutoPostBack="false" TextMode="MultiLine"></asp:TextBox>
</div>
<div id="commands">
<table cellpadding="0" cellspacing="0" width="400px" id="tblCommands">
<tr>
<td style="width: 50%; text-align: center;">
<asp:LinkButton ID="lnbInsertRes" runat="server" CommandName="Insert" Font-Underline="false">Insert</asp:LinkButton>
</td>
<td style="width: 50%; text-align: center;">
<asp:LinkButton ID="lnbCancelRes" runat="server" CommandName="Cancel" Font-Underline="false">Cancel</asp:LinkButton>
</td>
</tr>
</table>
</div>
</form>
</body>
<script type="text/javascript">
$(function()
{
$("#commands").hide("normal");
$("textarea[id$=txtInsertComments]").focus(function()
{
$("#commands").show("normal");
});
});
</script>
</html>
首先,這個頁面載入時,在div #command加載非常快,然後消失。我需要該div保持隱藏狀態,直到文本框txtInsertComments控件被點擊或獲得焦點。
二,當用戶點擊文本框txtInsertComments或文本框失去焦點時,div#命令仍然存在,並且不隱藏。
任何幫助表示讚賞。
非常感謝您的快速回復。有用! – Chuck 2009-11-30 17:06:44
好的,你們給我看的代碼適用於基本的asp.net頁面。有沒有人有使用jQuery嵌套ListView控件的經驗?這個相同的jQuery不適用於嵌套的ListView控件。 – Chuck 2009-11-30 17:23:44
非常感謝;)此代碼是完美的;) – Schewns 2012-12-26 16:17:30