user1721135
user1721135

Reputation: 7092

what event do i need in jquery to do something "ondrag"

Im trying to change some css once the user starts dragging something, but havent found a simple way to do this.

Right now im using mousedown and mouseon, the only problem is mousedown behaves exactly like click(), but id like the function to be executed once the user drags the element, not immedietly when its clicked.

There ought to be a simple way to do this but i havent found any. Is there a special jquery event for this?

How could i do this, so it works in all browsers?

here my application:

http://jsbin.com/ucopun/97/edit

Relevant code:

$("#myTable").on('mousedown', 'td', function(event) {
  $("td").css({'background-color': '#313131'});
});
$("#myTable").on('mouseup', 'td', function(event) {
  $("td").css({'background-color': '#fff'});
});

Upvotes: 0

Views: 96

Answers (1)

Tomandhisjones
Tomandhisjones

Reputation: 98

jQuery UI has a built in "draggable" plugin, that will probably allow you to achieve what you are looking for:

http://jqueryui.com/draggable/

Upvotes: 2

Related Questions