Edit The Code:
See Result »
Try it Yourself - ©
w3big.com
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>本教程(w3big.com)</title> <script src="http://cdn.static.w3big.com/libs/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("div:has(p,span,li)").css("border","solid red"); }); </script> </head> <body> <div> <p> div 中的 p 元素 <span>这是 span 元素</span> </p> <li>div 中的列表项</li> </div><br> <div>这个 div 元素没有 p, span 或 li 元素。</div> </body> </html>