给大家分享一个用原生JS编写的拖拽及拖拽方法继承的 小Demo,代码如下。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>原生JS中的拖拽方法继承</title>
<style>
#one {
width: 100px;
height: 100px;
background: red;
position: absolute;
}
#two {
width: 100px;
height: 100px;
background: yellow;
position: absolute;
}
</style>
</head>
<body>
<div id="one"></div>
<div id="two"></div>
<script>
// 定义拖拽父级对象
function Drag(id) {
var that = this;