如何在jQuery中获取图片的当前位置? [英] How to get current position of an image in jQuery?

查看:1547
本文介绍了如何在jQuery中获取图片的当前位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在开发一个具有背景的图像处理脚本,用户可以将一个或多个图像上传到该背景。我希望用户能够拖动和移动BG,最终可以生成最终的图像。但是,我不知道如何在BG上获得可拖动图像位置的位置。我一直在搜索互联网和电子书,但没有线索。请给我一些方式,我会等待你的宝贵答复。

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.

推荐答案

看看 position()

var pos = $("#myimage").position(); // returns an object with the attribute top and left
pos.top;  // top offset position
pos.left; // left offset position

这篇关于如何在jQuery中获取图片的当前位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆