编辑下面的代码:【加编码】
<html> <head> <script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("p").filter($("div p.intro")).css("background-color","yellow"); }); </script> </head> <body> <div style="border:1px solid black;"> This is a div element <h1>Welcome to My Homepage</h1> <p>My name is Donald.</p> <p class="intro">I live in Duckburg (will be selected).</p> <p>My best friend is Mickey.</p> </div> <p class="intro">This p element is outside the div element.</p> <p>This p element is also outside the div element.</p> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂