编辑下面的代码:【加编码】
<html> <head> <script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("p").not(function(){ return $("span",this).length==2;}).css("background-color","yellow"); }); </script> </head> <body> <div> <p>A p element <span>with one span element.</span></p> <p>A p element <span>with</span> two <span>span elements.</span></p> <p>A p element <span>with one span element.</span></p> <p>A p element <span>with</span> two <span>span elements.</span></p> <p>A p element with no span element.</p> </div> <div>This example returns all p elements that do not have two span elements.</div> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂