/------------------js部分------------------------- /
$(function(){
$("#b").mousedown(function(e){
var y0=e.offsetY;
var top0=parseInt($(this).css("top"));
$(document).bind('mousemove',event,movey);
$(document).mouseup(function(){
$(document).unbind("mousemove");
})
//定义鼠标移动时执行的函数
function movey(){
var y1=event.offsetY;
var dis=y1-y0;
var bili=(dis+y0) / ( $("#a").height()-$("#b").height() )
if(bili>=0&&bili<=1)
$("#b").css("top",dis+top0);
else if (bili>1)
$("#b").css("top",$("#a").height()-$("#b").height());
else
$("#b").css("top","0px");
}
}).mouseup(function(){
$(document).unbind("mousemove"); //不能只给document绑定事件
})
})
问题是为什么鼠标唾液的时候,滚动条会闪动,求大神指点
代码:https://jsfiddle.net/bbux0h7v/2/
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
没有取消浏览器的默认事件。