简体   繁体   中英

how to catch this event that when i left click and then move some where (not drag some div ) on a div

this is my code:

$('#handle').mousedown(function(e){
if( (!$.browser.msie && e.button == 0) || ($.browser.msie && e.button == 1) ) {
       alert("Left Button");
    }
})

this event is like to drag , but not drag ,

the left button Has been pressed, no released until mouseup,

so how to catch it using jquery ,

this is my demo : http://jsfiddle.net/ATZNW/1/

thanks

jQuery doesn't do this out of the box but you can fire your own events. Instead of alerting "left button", set some global variable dragging to true. Then:

$("#handle").mousemove(function (e) {
   if (dragging) {
      $(this).trigger("dragmove");
      // Or just write the code you need here
   }
});

Then you can handle that event elsewhere if you wish:

$("#handle").bind("dragmove", function (e) {

});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM