编辑下面的代码:【加编码】
<html> <head> <script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("div span").css("background-color","yellow"); }); </script> </head> <body> <h2>看看 $("div span") 会选中哪一部分呢?</h2> <h4>This div element has two descendants, p and span:</h4> <div style="border:1px solid black;padding:10px;"> <p>This is a paragraph.</p> <span>This is a text inside a span.</span> </div> <h4>This div element has also two descendants, p and span:</h4> <div style="border:1px solid black;padding:10px;"> <p>This is a paragraph. <span>This is a span element, inside the paragraph.</span></p> </div> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂