javascript - Change mouse pointer when dragging in HTML - Stack Overflow

I have a web page where I have built a simple drag and drop scheme.I have used user-select:none to ke

I have a web page where I have built a simple drag and drop scheme. I have used user-select:none to keep the text from being selected as I drag, and set cursor:pointer to keep the text-select bar from appearing when the user mouses over text. Unfortunately, when they hold the mouse button and drag an item around, the pointer changes to the I bar as if they were currently selecting text. Is there any way to change this behavior? Thanks!

I have a web page where I have built a simple drag and drop scheme. I have used user-select:none to keep the text from being selected as I drag, and set cursor:pointer to keep the text-select bar from appearing when the user mouses over text. Unfortunately, when they hold the mouse button and drag an item around, the pointer changes to the I bar as if they were currently selecting text. Is there any way to change this behavior? Thanks!

Share Improve this question asked Feb 16, 2012 at 16:08 Joshua SmithJoshua Smith 571 silver badge4 bronze badges 1
  • 1 add a class to a dragged element and set rules on it? – Madara's Ghost Commented Feb 16, 2012 at 16:10
Add a ment  | 

2 Answers 2

Reset to default 5

Is there any way to change this behavior?

Yes. You need to call prevent default on the mouse down event when you detect the user dragging the appropriate item.

Whenever I implement drag-and-drop, I place a mask over the entire page to capture the mousemove event wherever it may be. This mask has the relevant cursor set, usually cursor: move;.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744409746a4572814.html

相关推荐

  • javascript - Change mouse pointer when dragging in HTML - Stack Overflow

    I have a web page where I have built a simple drag and drop scheme.I have used user-select:none to ke

    8天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信