2016-12-13 53 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>