problem with jquery move image
how can get x,y when mousedown in image and then mouse move in the image and then mouseup get x,y
(2 x,y 1-x,y when mouse down 2-x,y when mouse up) al开发者_如何学Gol the event in the one image. and language jquery
this my code by this not working(image stick to mouse and only mouse_d called)
var mx1; var my1;
$("document").ready(function () { $("img#ground").bind("mousedown",mouse_d); $("img#ground").bind("mouseup",mouse_u); $("img#ground").bind("dragstart",mouse_d); });
function mouse_d(event)
{
mx1=event.pageX;
my1=event.pageY;
}
function mouse_u(e)
{
mx2=e.pageX;
my2=e.pageY;
mx2=mx1-mx2;
my2=my1-my2;
}
Are you trying to achieve a drag and drop effect?
if so this is the ultimate solution: http://jqueryui.com/demos/draggable/
when using firefox is the isNS variable true? otherwise an mouseup event isn't set.
精彩评论