<html lang="en">
<head>
<title>jQuery parents() Method to Get All Parent Elements</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('.mybtn').click(function(){
$("ul li b").parents().css({"color":"orange","border":"1px solid red","padding":"10px"});
});
});
</script>
</head>
<body>
<h2>jQuery parents() Method to Get All Parent Elements</h2>
<div>Great-Grandparent
<ul>Grandparent
<li>Parent
<b>Copy and use the codes on your project.</b>
</li>
</ul>
</div>
<button type="button" class="mybtn">Click to Get All Parents</button>
</body>
</html>