<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <script src="./js/jquery.min.js"></script> </head> <body> <ul> <li>1</li> <li class="item">2</li> <li>3</li> </ul> <script> $(function() { //兄弟元素 $("ol .item").siblings("li").css("color", "red"); //第n个元素 //我们可以选择选择器选择 $("ul li:eq(2)").css("color", "blue"); }) //判断是否有类名 console.log($("div:first").hasClass("current")); console.log($("div:last").hasClass("current")); </script> </body> </html>