jQuery CSS 操作 - offsetParent() 方法
實例
設置最近的祖先定位元素的背景顏色:
$("button").click(function(){ $("p").offsetParent()
.css("background-color","red"); });
定義和用法
offsetParent() 方法返回最近的祖先定位元素。
定位元素指的是元素的 CSS position 屬性被設置為 relative、absolute 或 fixed 的元素。
可以通過 jQuery 設置 position,或者通過 CSS 的 position 屬性。
語法
$(selector).offsetParent()
posted on 2014-04-11 17:27 順其自然EVO 閱讀(172) 評論(0) 編輯 收藏 所屬分類: jQuery