jQuery offsetParent() 方法

jQuery 教程 · 2019-03-27 15:29:28

实例

设置 <p> 元素的最近定位的祖先元素的背景颜色:

$("button").click(function(){ $("p").offsetParent().css("background-color","red"); });

定义和用法

offsetParent() 方法返回第一个定位的祖先元素。

提示:通过 jQuery 或 CSS 的 position 属性(relative、absolute 或 fixed)对元素进行定位。

语法

$(selector).offsetParent()

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

查看所有标签

Designing Web Navigation

Designing Web Navigation

James Kalbach / O'Reilly Media / 2007-8-15 / USD 49.99

Thoroughly rewritten for today's web environment, this bestselling book offers a fresh look at a fundamental topic of web site development: navigation design. Amid all the changes to the Web in the pa......一起来看看 《Designing Web Navigation》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

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

RGB CMYK 互转工具