使用Jquery获取图像的位置 [英] Get the position of an image using Jquery

查看:116
本文介绍了使用Jquery获取图像的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用Jquery获得图像的位置。
唯一的问题是,它只给了我
图像的位置,当文档被加载时。

 <$ c $ ()。$(。frog)。position()。left); 
});

如何在图片被移动后获取图片的位置?



/ Johannes

解决方案

.position 给出相对于父母的位置
.offset 给出了相对于文档的位置

I'm trying to get the position of an image using Jquery. The only problem is that it only gives me the position where the image where when the document loaded.

$(".frog").click(function(){
    alert($(".frog").position().left);  
});

How do I get the position of the image after it been moved?

/Johannes

解决方案

.position gives the position relative to the parent .offset gives the position relative to the document

这篇关于使用Jquery获取图像的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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