您好,我从 w3.org 复制了有关拖放的示例
http://www.w3.org/html/wg/drafts/html/master/editing.html#dnd
<p>What fruits do you like?</p>
<ol ondragstart="dragStartHandler(event)">
<li draggable="true" data-value="fruit-apple">Apples</li>
<li draggable="true" data-value="fruit-orange">Oranges</li>
<li draggable="true" data-value="fruit-pear">Pears</li>
</ol>
<script>
var internalDNDType = 'text/x-example'; // set this to something specific to your site
function dragStartHandler(event) {
if (event.target instanceof HTMLLIElement) {
// use the element's data-value="" attribute as the value to be moving:
event.dataTransfer.setData(internalDNDType, event.target.dataset.value);
event.dataTransfer.effectAllowed = 'move'; // only allow moves
} else {
event.preventDefault(); // don't allow selection to be dragged
}
}
</script>
它似乎不适用于我的 jsfiddle
http://jsfiddle.net/sivi/3YSLL/
有人可以指出我的问题。我对编程很陌生,所以任何帮助都会被磨碎。