拖动时更改光标

编程入门 行业动态 更新时间:2024-10-24 10:17:22
本文介绍了拖动时更改光标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否可以在拖动时更改光标?我一直在搜索并尝试这样做已有一段时间了.我想更改将对象拖动到另一个光标时显示的不允许"光标. 我尝试创建一个事件并将其分配给要拖动的图像:-

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="www.surfixe/img/tick2.png" draggable="true" ondragstart="drag(event)" />

java:-

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

jsfiddle

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()方法 api.jqueryui/draggable/ 它具有自己的选项,可以在拖动时使用特定的光标.

The 'not-allowed' cursor simply showed that there´s been no draggable at all. You have to bind your img with .draggable() method api.jqueryui/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" });

jsfiddle/wpcbM/3/

更多推荐

拖动时更改光标

本文发布于:2023-07-31 07:30:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1256736.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:光标   拖动

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!