dragstart上的jQuery / javascript更改元素

时间:2014-09-04 12:47:24

标签: javascript jquery drag-and-drop

如何将元素的dragstart事件分配(传输,...)到其他元素?

HTML:

<div draggable="true" ondragstart="drag(event)"> draggable </div>

<div ondrop="drop(event)" ondragover="dragover(event)"> droppable </div>

JS:

$(document).ready(function(){   
    $(document).mousemove(function(event) {
        $('.drag-panel').css({"top":event.pageY-70+'px',"left":event.pageX-70+'px'});
        Mouse.x = event.pageX;
        Mouse.y = event.pageY;
    });
});
function drag(event){ 
   event.preventDefault(); 
   var panel = $('.drag-panel')[0];             
   $(panel).css({"top":Mouse.y-70+'px',"left":Mouse.x-70+'px',"display":"block"});
   //and continue dragging with $(panel) ??
}

function dragover(event){
    alert('dragover'); 
}

有没有办法在调用drag()时更改拖动元素?

0 个答案:

没有答案