原生js实现拖拽排序
思路 –拖动元素得到位置确定元素对应的数据,在数组中位置– 代码部分 css样式 * { margin : 0 ; padding : 0 ; } #drag { width : 300px ; } .de-p { font-size : 20px ; line-height : 80px ; text-align : center ; height : 80px ; width : 80px ; border : 1px solid #e2e2e2 ; background-color : rgba ( 16, 15, 245,.5 ) ; cursor : pointer ; color : antiquewhite ; float : left ; } ._absolute { position : absolute ; opacity : 0.3 ; } ._relative { position : relative ; } html <div id= "drag" ></div> js拖拽对象实例化 var list = [ { name : '1' } , { name : '2' } , { name : '3' } , { name : '4' } , { name : '5' } , { name : '6' } , { name : '7' } , {