html5移动端拖拽
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> </head> <body> <div class="bbs_sign" id="bbsSi" draggable="true"><img src="img/bi.png">我要发帖</div>
<script type="text/javascript"> var bbsSi=document.getElementById("bbsSi"); //监听 bbsSi.addEventListener('touchmove',function(event){ //阻止默认 event.preventDefault(); //判断是否是一个手指 if(event.targetTouches.length==1) { //拖拽最后的位置 var touch = event.targetTouches[0]; bbsSi.style.right = 0; bbsSi.style.top = touch.pageY + 'px'; } },false); </script>
</body> </html>