简体   繁体   English

Cursor 拖放

[英]Cursor Drag and Drop

I found a function to move an element from one div to another and work very well, but when i drag element the cursor change to cursor: not-allowed;我发现了一个 function 将一个元素从一个 div 移动到另一个并且工作得很好,但是当我拖动元素时 cursor 更改为cursor: not-allowed; or something similar, but I want change cursor to cursor: grab;或类似的东西,但我想将 cursor 更改为cursor: grab; when i move the element, how i can do this?当我移动元素时,我该怎么做?

Is the same example of this question: Example是不是这个问题的同一个例子: 例子

I try:我尝试:

#piece:focus{
cursor: grab;
}
#piece:selection{
cursor: grab;
}
#piece:hover{
cursor: grab;
}

You could, in dragStart , add e.target.classList.add('grabbed');您可以在dragStart中添加e.target.classList.add('grabbed'); and in dragEnd , add e.target.classList.remove('grabbed');并在dragEnd中添加e.target.classList.remove('grabbed'); . .

Then add css .grabbed { cursor: grab; }然后添加 ZC7A62 .grabbed { cursor: grab; } .grabbed { cursor: grab; } . .grabbed { cursor: grab; }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM