<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>可拖动</title>
</head>
<body>
<div id="source" style="width:80px;height:80px;border:1px solid black;background-color:red;"draggable="true">百度</div>
<script type="text/javascript">
var source=document.getElementById("source");
source.ondragstart=function(evt){
evt.dataTransfer.setData("text","http://www.baidu.com");
}
document.ondragover=function(evt){
return false;
}
document.ondrop=function(evt){
source.style.position="absolute";
source.style.left=evt.pageX+"px";
source.style.top=evt.pageY+"px";
return false;
}
</script>
</body>
</html>
html拖放
最新推荐文章于 2024-04-09 17:34:36 发布