为什么我后面的这些代码都有问题?<!DOCTYPE html><html> <head> <title>:first过滤选择器</title> <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js" type="text/javascript"></script> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <div>改变最后一行"苹果"背景颜色:</div> <div> <ol id="test"> <li id="test1">葡萄</li> <li id="test1">香蕉</li> <li id="test1">橘子</li> <li id="test1">西瓜</li> <li id="test1">苹果</li></ol> </div> <div> <ol id="test"> <li id="test1">葡萄</li> <li id="test1">香蕉</li> <li id="test1">橘子</li> <li id="test1">西瓜</li> <li id="test1">苹果</li></ol> </div> <div><ol id="test"> <li id="test1">葡萄</li> <li id="test1">香蕉</li> <li id="test1">橘子</li> <li id="test1">西瓜</li> <li id="test1">苹果</li></ol> </div> <script type="text/javascript"> //$("div:first").css("background-color", "red"); //$("ol:last").css("background-color", "red"); $("div:last").css("background-color", "red"); $("div:last").css("background-color", "red"); $("#test:last").css("background-color", "red"); $("#test1:last").css("background-color", "red"); </script> </body></html>
添加回答
举报
0/150
提交
取消