<!DOCTYPE html> <html> <head> <title></title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script language="javascript" src="https://code.jquery.com/jquery-3.1.1.min.js"></script> <style type="text/css"> .active { background: blue; height: 40px; line-height: 40px; color: white; } </style> <script language="javascript"> $(document).ready(function(){ $(".my-class:parent").addClass('active'); }); </script> </head> <body> <div> <p class="my-class">Messi có 5 quả bóng vàng</p> </div> <div> <h3 class="my-class">Ronaldo cũng vậy</h3> </div> <div> <p class="my-class"></p> </div> </body> </html>