拖动时拖动更改光标

拖动时拖动更改光标

本文介绍了HTML5 Drag&拖动时拖动更改光标(不要使用UI)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在拖动时更改光标,所以我尝试这样:



  function drag(event){localStorage.setItem(no,$(event.target).data(no)); $(html)。css(cursor,move);}  
 < tr draggable =trueclass =memo_item moveid =memo_<?php echo $ memo> memo_no?> ondragstart =drag(event,this); data-no =<?php echo $ memo> memo_no?>>< / tr>  

/ p>

但它不起作用。



我不能使用 JQueryUi



如何更改游标?

解决方案
  $('< some element here>' ).on('dragstart',function(){
$(this).css(cursor,move);
});

但是,这将永久地更改元素上的光标,以切换此光标更改添加

  $('< some element here>')on('dragend',function(){
$ ).css(cursor,default); //或任何要还原到
}的指针);


I want to change the cursor when dragging, so I try this way:

function drag (event) {

    localStorage.setItem("no", $(event.target).data("no"));

    $("html").css("cursor", "move");

}
<tr draggable="true" class="memo_item move" id="memo_<?php echo $memo->memo_no?>" ondragstart="drag(event, this);" data-no="<?php echo $memo->memo_no?>"></tr>

but it doesn't work.

And I can't use JQueryUi.

How can I change cursor?

解决方案

Simply implement this kind of event setup in your code...

$('<some element here>').on('dragstart', function() {
  $(this).css("cursor", "move");
});

However, this will permanently change the cursor on the element, to toggle this cursor change add

$('<some element here>').on('dragend', function() {
  $(this).css("cursor", "default"); // or whatever pointer you want to revert to
});

这篇关于HTML5 Drag&amp;拖动时拖动更改光标(不要使用UI)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 15:36