jQuery offset() 方法
jQuery 教程
· 2019-03-27 15:12:29
实例
返回 <p> 元素的偏移坐标:
$("button").click(function(){
var x=$("p").offset();
alert("Top: " + x.top + " Left: " + x.left);
});
定义和用法
offset() 方法设置或返回被选元素相对于文档的偏移坐标。
当用于返回偏移时:
该方法返回第一个匹配元素的偏移坐标。它返回一个带有两个属性(以像素为单位的 top 和 left 位置)的对象。
当用于设置偏移时:
该方法设置所有匹配元素的偏移坐标。
语法
返回偏移坐标:
$(selector).offset()
设置偏移坐标:
$(selector).offset({top:value,left:value})
使用函数设置偏移坐标:
$(selector).offset(function(index,currentoffset))
| 参数 | 描述 |
|---|---|
| {top:value,left:value} | 当设置偏移时是必需的。规定以像素为单位的 top 和 left 坐标。 可能的值:
|
| function(index,currentoffset) | 可选。规定返回包含 top 和 left 坐标的对象的函数。
|
点击查看所有 jQuery 教程 文章: https://codercto.com/courses/l/35.html
具体数学(英文版第2版)
[美] Ronald L. Graham、Donald E. Knuth、Oren Patashnik / 机械工业出版社 / 2002-8 / 49.00元
This book introduces the mathematics that supports advanced computer Programming and the analysis of algorithms. The primary aim of its well-known authors is to provide a solid and relevant base of ma......一起来看看 《具体数学(英文版第2版)》 这本书的介绍吧!