我想在一次行动后展示一个div。现在,我将只使用一个按钮单击事件。
这是我的jquery函数:
function hideMessageBlock() {
$('.alert').delay(5000).fadeOut('slow');
}我也试过这个:
$(document).ready(function(){
console.log('READY to animate');
function hideMessageBlock() {
$('.alert').delay(5000).fadeOut('slow');
}
});在我后面的代码中,我有以下代码:
protected void Button1_Click(object sender, EventArgs e)
{
alertSuccessBlock.Visible = true;
lbl_alertSuccessBlock.Text = "Animate this block with timeout!";
ScriptManager.RegisterStartupScript(this, this.GetType(), "ScriptManager1", "hideMessageBlock();", true);
}在aspx中,我在我使用的脚本之后声明了一个脚本管理器(表单和正文闭包之前的页面底部):
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>我收到的错误是: ReferenceError: hideMessageBlock没有定义,函数在加载整个jquery脚本之前被调用(只是猜测)
我怎样才能解决这个问题?
发布于 2014-11-27 14:36:33
我已经解决了这个问题。我不得不将函数定义移到document.ready回调之外。
https://stackoverflow.com/questions/27172921
复制相似问题