【问题标题】:Get the position of an image using Jquery使用 Jquery 获取图像的位置
【发布时间】:2012-11-18 01:03:34
【问题描述】:

我正在尝试使用 Jquery 获取图像的位置。 唯一的问题是它只给了我一个位置 加载文档时的图像。

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

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

/约翰内斯

【问题讨论】:

  • 用$(".frog").offset()怎么样?
  • 谢谢,offset 让它工作了:)

标签: javascript jquery html image


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-30
    • 1970-01-01
    相关资源
    最近更新 更多