关闭$(document).load

时间:2012-03-15 22:43:02

标签: jquery

我有......

$(document).load("Hi",function CheckHi() {
    // Do Stuff
 });

如何阻止Hi运行?我想说...

$(window).off("Hi");

但我知道这不对。

1 个答案:

答案 0 :(得分:1)

我想你想要.unbind()

$(document).unbind('load');

我不确定"Hi"在那里做了什么 - the .load() signature中没有字符串参数,甚至可能导致jQuery认为你的意思是the other .load() method (虽然我没有测试过)。如果要再次引用该函数以取消绑定它,则需要在方法调用之外命名它:

function checkHi() {
    // Do Stuff
}

$(document).load(checkHi);
// later...
$(document).unbind('load', checkHi);
相关问题