Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get current position of an image in jQuery?

Tags:

jquery

dom

I've been developing a image manipulation script which has a background and user can upload one or more images onto that background. I want users to be able to drag and move around the BG and finally they can generate final image. However, I have no idea how to get the position of draggable image position on BG. I've been searching around the Internet and ebooks but no clue. Please show me some way and I'll be waiting for your precious replies.

like image 895
Devyn Avatar asked May 19 '09 21:05

Devyn


1 Answers

Take a look at position():

var pos = $("#myimage").position(); // returns an object with the attribute top and left
pos.top;  // top offset position
pos.left; // left offset position
like image 178
Gumbo Avatar answered Oct 11 '22 23:10

Gumbo