Select parent by class name
Description
The following code shows how to select parent by class name.
Example
<html>
<head>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {<!--from w w w. j a v a2 s . c om-->
$("p").parent(".selected").css("background", "yellow");
});
</script>
<style>
.y {
background: yellow;
}
</style>
</head>
<body>
<div>
<span class="selected">java2s.com
<p></p>
</span> <span>java2s.com</span>
</div>
</body>
</html>