2016-12-13 107 views

回答

3

要做到这一点,你可以用拖动库cursor财产,像这样:

$("#draggable").draggable({ 
    cursor: 'crosshair' 
}); 

或者,如果你要设置通过CSS自定义光标你将需要使用jQuery可拖动库的startend事件来更改ui.helper的CSS cursor属性。试试这个:

$("#draggable").draggable({ 
 
    start: function(e, ui) { 
 
    ui.helper.addClass('dragging'); 
 
    }, 
 
    stop: function(e, ui) { 
 
    ui.helper.removeClass('dragging'); 
 
    } 
 
});
.dragging { cursor: url('http://i.imgur.com/6r4pI7U.png'), crosshair; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<script src="http://code.jquery.com/ui/1.12.0/jquery-ui.min.js"></script> 
 
<div id="draggable"> 
 
    <p>Drag me</p> 
 
</div>