0

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'});
});
user1721135
  • 6,864
  • 8
  • 34
  • 63
  • 1
    Why aren't you using the `drag` event handler, as described in the [jQuery UI documentation](http://api.jqueryui.com/draggable/#event-drag)? – Barmar Dec 31 '12 at 17:58

1 Answers1

2

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

http://jqueryui.com/draggable/