Denis Bozhkov
Denis Bozhkov

Reputation: 11

How to changed cursor when you drag object

css

.draggable,
.draggable * {
    cursor: url('img/arrowHand.png'), auto;
}

js

$('body').on('dragstart', function () {
    $('body').addClass('draggable');
});
$('body').on('dragend', function () {
    $('body').removeClass('draggable');
});

The class is assigned, the cursor image is loaded, but used the standard cursor when you drag the object. What needs to change?

Upvotes: 0

Views: 65

Answers (3)

Ganesh Putta
Ganesh Putta

Reputation: 2671

Just add this to your draggable class, then it works fine

 cursor : move;

Upvotes: 0

Editor
Editor

Reputation: 632

You can see demo also you dont need javascript code for cursor

JSFiddle Demo

Upvotes: 0

Engkus Kusnadi
Engkus Kusnadi

Reputation: 2506

Just add this style

body.draggable {
   cursor : move;
}

See the full example http://www.w3schools.com/cssref/tryit.asp?filename=trycss_cursor

Upvotes: 1

Related Questions