编辑下面的代码:【加编码】
<html> <head> <script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("p:only-of-type").css("background-color","yellow"); }); </script> </head> <body> <div style="border:1px solid;"> <p>The first paragraph.</p> <p>The last paragraph.</p> </div><br> <div style="border:1px solid;"> <p>The only paragraph.</p> </div><br> <div style="border:1px solid;"> <span>This is a span element.</span> <p>The only paragraph.</p> </div><br> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂