jQuery初心者はこちら:
ボタンのクリック時にメッセージを表示し、数秒後にフェードする次のメッセージ div があります。これはうまくいきます。ただし、ページの読み込み時にメッセージ div を非表示にし、ボタンのクリック時に表示したいと思います。
これまでのところ、hideDiv クラスをメッセージ div に追加しようとしましたが、messageDiv がまったく表示されません (ロード時またはボタン クリック時)。また、Div をラップする親を非表示/表示しようとしました (ここには表示されていません)。
提案?
<div id="messageDiv" runat="server" class="alert">Row Deleted</div>
.
<style type="text/css">
.alert{display:block;width:100%;color:#900000;font-size: 1.4em;}
.hideDiv{display:none;}
</style>
.
<script type="text/javascript">
$(document).ready(function () {
$(document.getElementById('<%= messageDiv.ClientID %>')).addClass("alert"); setTimeout(function () {
$(document.getElementById('<%= messageDiv.ClientID %>')).fadeOut("slow", function () {
$(document.getElementById('<%= messageDiv.ClientID %>')).remove();
});
}, 4000);
});
</script>
.
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
protected void Button1_Click(object sender, EventArgs e)
{messageDiv.InnerText = "Row Action Completed";}