jQuery offsetParent() 方法
實例
設置<p> 元素的最近的被定位的父元素的背景顏色:
$("button").click(function(){
$("p").offsetParent().css("background-color","red");
});
$("p").offsetParent().css("background-color","red");
});
嘗試一下»
定義和用法
offsetParent() 方法返回第一個被定位的父元素。
提示:元素可通過jQuery或CSS的position屬性(relative、absolute或fixed)來定位。
語法
$(selector).offsetParent()