has
RUN
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <style> .active { background: red; height: 30px; color: #fff; } </style> <script src="https://code.jquery.com/jquery-2.0.0.js"></script> </head> <body> <div>Không có chứa thẻ p</div> <div> <p>Nội dung có chứa thẻ p</p> </div> <script> $("div:has(p)").addClass("active"); </script> </body> </html>
PHÓNG TO