Javascript 飞到购物车效果-通用图像
尝试到处搜索,但找不到解决方案,所以就这样 基于以下脚本-Javascript 飞到购物车效果-通用图像,javascript,jquery,jquery-animate,effect,Javascript,Jquery,Jquery Animate,Effect,尝试到处搜索,但找不到解决方案,所以就这样 基于以下脚本- 与其让页面上呈现的图像飞到购物篮,我如何用通用图像覆盖它例如:-我将使用的路径是图像文件夹。如果您想将产品图像更改为自定义图像,那么您可以通过更改 您的代码来自: var imgclone = imgtodrag.clone() .offset({ top: imgtodrag.offset().top,
与其让页面上呈现的图像飞到购物篮,我如何用通用图像覆盖它例如:-我将使用的路径是图像文件夹。如果您想将产品图像更改为自定义图像,那么您可以通过更改 您的代码来自:
var imgclone = imgtodrag.clone()
.offset({
top: imgtodrag.offset().top,
left: imgtodrag.offset().left
}) // ...
致:
//飞到购物车的图像。
var$img_to_move=$('');
//使用该图像
var imgclone=$img\u to\u move.offset({
顶部:imgtodrag.offset().top,
左:imgtodrag.offset().左
}) // ...
在此处查看工作示例:
当然,也可以更改
imgClone
变量的名称,使其与所做的匹配,甚至可以删除它,只需使用$img\u在代码中进一步移动。没有更改它以获得许可。我从这里找到了jQuery飞到购物车效果的最佳解决方案-
这个脚本的用法非常简单,如下所示
$(document).ready(function(){
$('.add-to-cart').on('click',function(){
//Scroll to top if cart icon is hidden on top
$('html, body').animate({
'scrollTop' : $(".cart_anchor").position().top
});
//Select item image and pass to the function
var itemImg = $(this).parent().find('img').eq(0);
flyToElement($(itemImg), $('.cart_anchor'));
});
});
$(document).ready(function(){
$('.add-to-cart').on('click',function(){
//Scroll to top if cart icon is hidden on top
$('html, body').animate({
'scrollTop' : $(".cart_anchor").position().top
});
//Select item image and pass to the function
var itemImg = $(this).parent().find('img').eq(0);
flyToElement($(itemImg), $('.cart_anchor'));
});
});