html實現拖動的完整代碼

來源:互聯網
上載者:User
本篇文章給大家帶來的內容是關於css中flaot浮動的原因及帶來的問題分析 ,有一定的參考價值,有需要的朋友可以參考一下,希望對你有所協助。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><title>drag</title><style type="text/css">#p1{width :100px; height :30px;border:1px solid red; }</style><script type="text/javascript">function allowDrop(ev){ev.preventDefault();}function drag(ev){ev.dataTransfer.setData("Text",ev.target.id);}function drop(ev){ev.preventDefault();var data = ev.dataTransfer.getData("Text");ev.target.appendChild(document.getElementById(data));}</script></head><body><p id="p1" ondrop="drop(event)" ondragover="allowDrop(event)"></p><br><p id="drag1" draggable="true" ondragstart="drag(event)" >鎷栧姩</p></body></html>
相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.