[英]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 , 那么如何使用jquery捕获它,
this is my demo : http://jsfiddle.net/ATZNW/1/ 这是我的演示: http : //jsfiddle.net/ATZNW/1/
thanks 谢谢
jQuery doesn't do this out of the box but you can fire your own events. jQuery并没有开箱即用,但是您可以触发自己的事件。 Instead of alerting "left button", set some global variable dragging
to true. 而不是警告“左键”,而是将一些全局变量dragging
为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) {
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.