fly icon indicating copy to clipboard operation
fly copied to clipboard

加入购物车时页面会自动滚到顶部

Open IrvingW opened this issue 8 years ago • 1 comments

如题,不知道该怎么解决 我的代码

$(".addcar").click(function(event){ 
 	var offset = $("#end").offset(); 
     var addcar = $(this); 
     var img = addcar.parent().find('img').attr('src'); 
     var flyer = $('<img class="u-flyer" src="'+img+'">'); 
     $ (window).unbind ('scroll');
     flyer.fly({ 
         start: { 
             left: event.pageX, //开始位置(必填)#fly元素会被设置成position: fixed 
             top: event.pageY //开始位置(必填) 
         }, 
         end: { 
             left: offset.left+10, //结束位置(必填) 
             top: offset.top+10, //结束位置(必填) 
             width: 0, //结束时宽度 
             height: 0 //结束时高度 
         }, 
         onEnd: function(){ //结束回调 
             $("#msg").show().animate({width: '250px'}, 200).fadeOut(1000); //提示信息 
				
         } 
     }); 
 }); 

IrvingW avatar May 27 '17 16:05 IrvingW

addcar 是a标签吧,href属性改为:javascript:;

joleye avatar Oct 12 '18 00:10 joleye