首页
极刻
圈子
教程
开源
极客社区
写文章
发极刻
建圈子
发项目
登录 / 注册
返回教程:jQuery 教程
TRY RUN / 在线示例
jQuery 教程 返回所有不是偶数号的 <p> 元素
jQuery 教程 返回所有不是偶数号的 <p> 元素
源代码
运行
<!DOCTYPE html> <html> <head> <script src="//libs.baidu.com/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("p").not(":even").css("background-color","yellow"); }); </script> </head> <body> <p>My name is Donald (index 0).</p> <p>I live in Duckburg (index 1).</p> <p>My best friend is Mickey (index 2).</p> <p>My name is Daisy (index 3).</p> <p>I live in Duckburg (index 4).</p> <p>My best friend is Minnie (index 5).</p> </body> </html>
运行结果