拖动时更改光标 [英] 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:-
function drag(ev) {
$('#drag1').css('cursor', 'pointer');
}
jsfiddle
注意:我的小项目被认为是html-5 drag and drop
,所以我需要能够在用html-5 drag attribute
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
推荐答案
不允许"光标仅表明根本没有可拖动的对象.
您必须使用.draggable()
方法 http://api.jqueryui.com/draggable/
它具有自己的选项,可以在拖动时使用特定的光标.
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.
您可以像使用它一样简单
you can use it as easy like
$( "#drag1" ).draggable({ cursor: "pointer" });
这篇关于拖动时更改光标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!