2011-12-22 245 views
1

使用說jQuery,我如何使用鼠標(或者光標)移動圖像,即圖像粘在指針上;我以後如何取消粘貼,或交換粘貼的圖像。謝謝使用鼠標移動圖像移動

+0

這將是'mousemove()'和'click()'事件的組合。閱讀API中的內容:http://api.jquery.com – 2011-12-22 08:58:04

回答

0

你正在尋找一個自定義的光標圖像?或者您是否想要拖動並移動頁面上已有的圖像?

如果它的前者,你可以在你的css文件中使用cursor: url(cursor.cur);

如果是後者,你可以做到這一點進行適當處理image's mousedowndocument's mousemove and mouseup事件。

0

如果你可以使用jQuery UI的,你可以使用:

上的mousedown應用以下(或versionof吧):

$(document).mousemove(function(ev){ 
    $("#theimage").position({ 
    my: "left bottom", 
    of: ev, 
    collision: "fit" 
    }); 
}); 

http://docs.jquery.com/UI/Position

和圖像的設定absoulute位置鼠標鬆開。