jQuery position() 方法

jQuery 教程 · 2019-03-27 16:13:28

实例

返回 <p> 元素的 top 和 left 位置:

$("button").click(function(){ x=$("p").position(); alert("Top: " + x.top + " Left: " + x.left); });

定义和用法

position() 方法返回第一个匹配元素的位置(相对于它的父元素)。

该方法返回一个带有两个属性(以像素为单位的 top 和 left 位置)的对象。

语法

$(selector).position()

点击查看所有 jQuery 教程 文章: https://codercto.com/courses/l/35.html

查看所有标签

Ruby on Rails Tutorial

Ruby on Rails Tutorial

Michael Hartl / Addison-Wesley Professional / 2012-8-6 / USD 44.99

"Ruby on Rails(TM) Tutorial by Michael Hartl has become a must-read for developers learning how to build Rails apps." -Peter Cooper, Editor of Ruby Inside Using Rails, developers can build web applica......一起来看看 《Ruby on Rails Tutorial》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具