簡體   English   中英

收到JavaScript錯誤:“X不是函數”

[英]Receiving a JavaScript error: “X is not function”

我想要做的是,動畫和隱藏一些div,在closelink按鈕單擊,然后隱藏此按鈕。 函數有效,但不隱藏closer_div並給出錯誤消息:

ftr_form_cntr.stop(true,true).animate({height:“0”},1000).pause不是函數

在Firefox上。 實際上它完成所有操作。 這一行closer_div.hide();

功能看起來像那樣

$(closer_link).click(function () {
    ftr_form_cntr.find("div").fadeOut();
    ftr_form_cntr.stop(true, true).animate({height:"0"},1000).pause(2000).hide();
    closer_div.hide();
});

animate函數確實具有將在動畫完成時觸發的回調函數,請參閱下面的代碼:

ftr_form_cntr.stop(true, true).animate({height:"0"},1000, function(){
    $(this).hide();
})

你也可以做什么,如果你想要一個高度為0並將其隱藏起來。 使用.slideUp()函數,這個函數也有一個回調函數。

ftr_form_cntr.stop(true, true).slideUp(1000);

如果你想動畫,等待1秒鍾並做一些其他事情,做一些類似的事情:

ftr_form_cntr.stop(true, true).animate({height:"0"},1000, function(){
    var _this = $(this);
    setTimeout(function(){
        _this.hide();
    }, 1000);
})

另一個選項可以是.delay() ,等待2秒。

ftr_form_cntr.stop(true, true).animate({height:"0"},1000).delay(2000).hide();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM