Correction status:qualified
Teacher's comments:
2、jQuery语句放到页面前方的话须使用$(document).ready()方法提前加载DOM部分
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>0402jquery的二种引入方式</title> <!-- jquery的二种引入方式 --> <!-- <script type="text/javascript" src="js/jquery.3.3.1.js"></script> --> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> <script type="text/javascript"> $(document).ready( function(){ $('ul>li:nth-child(2)~*').css('background-color','lightblue') }) </script> </head> <style type="text/css"> .box{width:500px;margin:0 auto;border:1px solid #eee;} ul{overflow: hidden;list-style: none;margin:0;padding: 0} .box ul li{float:left;width:40px;height:40px;text-align: center;line-height: 40px;background: lightgreen;border-radius: 50%;margin:20px;} </style> <body> <div class="box"> <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> </ul> </div> </body> </html>
点击 "运行实例" 按钮查看在线实例