简体   繁体   English

拖动时更改光标

[英]Changing cursor while dragging

Is it possible to change the cursor while dragging? 拖动时是否可以更改光标? I have been searching and trying to do it for a while now. 我一直在寻找并试图做一段时间。 I want to change the 'not-allowed' cursor which shows up while you drag an object to another cursor. 我想更改在将对象拖动到另一个光标时显示的“不允许”光标。

I tried creating an event and assigning it to the image I wanted to drag:- 我尝试创建一个事件并将其分配给我想要拖动的图像: -

<img id="drag1" class="drag" src="http://www.surfixe.com/img/tick2.png" draggable="true" ondragstart="drag(event)" />

java:- java的: -

function drag(ev) {
    $('#drag1').css('cursor', 'pointer');
}


jsfiddle 的jsfiddle

Edit: Note: My little project is suppost to be html-5 drag and drop , so I need to be able to change the cursor while dragging a div with html-5 drag attribute 编辑:注意:我的小项目是支持html-5 drag and drop ,所以我需要能够在使用html-5 drag attribute拖动div时更改光标

The 'not-allowed' cursor simply showed that there´s been no draggable at all. “不允许”光标只是表明根本没有拖拽。 You have to bind your img with .draggable() method http://api.jqueryui.com/draggable/ it has it´s own option for a specific cursor to be used while dragging. 你必须使用.draggable()方法绑定你的img http://api.jqueryui.com/draggable/它有自己的选项,可以在拖动时使用特定的游标。

you can use it as easy like 你可以像使用它一样轻松

$( "#drag1" ).draggable({ cursor: "pointer" });

http://jsfiddle.net/wpcbM/3/ http://jsfiddle.net/wpcbM/3/

Yes it is possible. 对的,这是可能的。 You should change the cursor of item that you are dragging (not the destination one). 您应该更改要拖动的项目的光标(而不是目标项目)。

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

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