js 实现滑块效果
var dd = $(".drag_bott").removeAttr('id').last().attr('id','drag_bott'); var drag = document.getElementById("drag_bott"); function moveButton(){ obj = this; var intX = event.targetTouches[0].pageX;//点击的X坐标 var intY = event.targetTouches[0].pageY;//点击的Y坐标 var right = $(obj).css('left'); var bottom = $(obj).css('bottom'); obj.addEventListener('touchmove', function(){ event.preventDefault(); var moveX = event.targetTouches[0].pageX;//动态获取鼠的X坐标 var moveY = event.targetTouches[0].pageY;//动态获取鼠的Y坐标 var disX = intX-moveX;//差值 var disY = moveY-intY;//差值 var movX = parseInt(right)-disX+'px';//目标right值 var movY = parseInt(bottom)-disY+'px';//目标bottom值 $(obj).css('left',movX); $(obj).css('bottom',movY); }); }; drag.addEventListener('touchstart',moveButton,false);
If the copyright belongs to the longfei, please indicate the source!!!