<html>
<head>
<script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").offsetParent().css("background-color","red");
});
});
</script>
</head>
<body>
<button>Set background-color</button>
<div style="border:1px solid black;width:70%;position:absolute;left:10px;top:50px">
<div style="border:1px solid black;margin:50px;background-color:yellow">
<p>Click button to set the background color of the first positioned parent element of this paragraph.</p>
</div></div>
</body>
</html>