Match parents
<html> <head> <style> .test{ border: 1px solid red; } </style> <script type="text/javascript" src="js/jquery-1.3.2.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("p:parent").addClass("test"); }); </script> </head> <body> <div><p>paragraph in div</p></div> <div>div</div> </body> </html>