0

Here's my simple jQuery code in which is used to hide/show a dynamic element

$('.network').click(function() {
    if($("a[data-network='all']").hasClass('active')) {
        if($(this).data("network") !== "all") {
            var network = $(this).data('network');
            switch(network) {
                case "fb":
                    $(".facebook").hide("slide", { direction: "up"  }, 2000);
                break;
                case "tw":

                break;
                case "all":

                break;
            }
        }
    } 
});

When running the click() function it's pushing Uncaught TypeError: Property '#<Object>' of object #<Object> is not a function to the console.log

The error is coming from this line

$(".facebook").hide("slide", { direction: "up"  }, 2000);

You need to use jQuery-ui along with jQuery to support this format of hide function.

The default hide() function provided by jQuery takes only two parameters - duration and complete callback, but the one provided by jQuery-UI support more options

So either you can include jQuery-UI to the project or change the code as

$(".facebook").slideUp(2000);
4

1 回答 1

3

您需要使用jQuery-ui和 jQuery 来支持这种格式的隐藏功能。

jQuery 提供的默认hide()函数只接受两个参数 - 持续时间和完成回调,但jQuery-UI 提供的一个支持更多选项

因此,您可以将 jQuery-UI 包含到项目中,也可以将代码更改为

$(".facebook").slideUp(2000);
于 2013-09-02T16:33:15.023 回答