【问题标题】:Cart to Fly Uncaught TypeError: Cannot read property 'top' of undefinedCart to Fly Uncaught TypeError:无法读取未定义的属性“顶部”
【发布时间】:2017-11-30 19:25:58
【问题描述】:

我正在尝试制作购物车飞行效果,但我收到一个错误,不知道为什么顶部被称为未定义。我已经能够将产品添加到购物篮中,但图像卡住并随机出现在屏幕上,而不是从父图像向上移动到购物车的动画

$('.add').on('click', function () {
        var cart = $('.cart');
        var imgtodrag = $('.zoomImg');
        if (imgtodrag) {
            var imgclone = imgtodrag.clone()
                .offset({
                top: imgtodrag.offset().top,
                left: imgtodrag.offset().left
            })
                .css({
                'opacity': '0.5',
                    'position': 'absolute',
                    'height': '150px',
                    'width': '150px',
                    'z-index': '100'
            })
                .appendTo($('body'))
                .animate({
                'top': cart.offset().top + 10,
                    'left': cart.offset().left + 10,
                    'width': 75,
                    'height': 75
            }, 1000, 'easeInOutExpo');

            setTimeout(function () {
                cart.effect("shake", {
                    times: 2
                }, 200);
            }, 1500);

            imgclone.animate({
                'width': 0,
                    'height': 0
            }, function () {
                $(this).detach()
            });
        }
    });

附: 我正在使用 Jquery 2.1.3 和 jqueryui 1.11.2

【问题讨论】:

    标签: javascript jquery html css jquery-ui


    【解决方案1】:

    已经想通了,某些页面上缺少元素导致错误

    【讨论】:

      猜你喜欢
      • 2014-12-31
      • 2021-04-28
      • 2017-07-20
      • 1970-01-01
      • 2020-03-28
      • 2023-04-11
      • 2016-04-22
      • 2015-06-08
      • 2014-03-17
      相关资源
      最近更新 更多