安科网
源代码:
点击运行
<!DOCTYPE html> <html> <head> <script src="//libs.baidu.com/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("p:nth-last-of-type(3n+2)").css("background-color","yellow"); }); </script> </head> <body> <p>The p:nth-child(3n+2) selects each 3rd paragraph, starting at the last 2nd paragraph (in this case the seventh p element). <div style="border:1px solid;"> <p>The first paragraph.</p> <p>The second paragraph.</p> <p>The third paragraph.</p> <p>The fourth paragraph.</p> <p>The fifth paragraph.</p> <p>The sixth paragraph.</p> <p>The seventh paragraph.</p> <p>The eight paragraph.</p> <span>This is a span element.</span> </div><br> </body> </html>
运行结果
Copyright © 2013 - 2019 Ancii.com All Rights Reserved
京ICP备18063983号-5
京公网安备11010802014868号