运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("div > span").css("background-color", "yellow"); }); </script> </head> <body> <h2>What will $("div > span") select?</h2> <h4>This div element has two direct child elements, 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 one direct child element, p:</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>