第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

HTML5 drag and drop 中出現(xiàn)錯誤

HTML5 drag and drop 中出現(xiàn)錯誤

sherryliu 2018-02-07 15:21:26
<!DOCTYPE?html> <html> <head> <meta?charset="UTF-8"> <title>Document</title> <style> #box{ width:300px; height:180px; border:1px?solid?#000; } #img1{ width:200px; height:120px; margin:?20px; } </style> </head> <body> <div?id="box"></div> <img?src="img/6.jpg"?id="img1"?draggable="true"> <script> window.onload=function(){ var?box=document.getElementById('box'), img1=document.getElementById('img1'); img1.ondragstart=drag(event); box.ondragover=allowdrop(event); box.ondrop=drop(event); 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> </body> </html>當我把ondragstart? ?ondragover? ?ondrop事件放在HTML元素標簽內時,代碼正常運行,但是像上邊放在<script>中時,就會出現(xiàn)錯誤Uncaught TypeError: Cannot read property 'setData' of undefined? 請問各位大神是哪里出了問題,怎么修改?
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 1134 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號