fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"> </script> <script> $(document).ready(function(){ $("button").click(function(){ $("li").removeClass(function(n) { if (n==0||n==1) {return "listitem"} else {return ""} }); }); }); </script> <style type="text/css"> .listitem{ color:red; } </style> </head> <body> <h1>这是一个标题</h1> <ul> <li class="listitem">Peter</li> <li class="listitem">Lois</li> <li class="listitem">Chris</li> <li class="listitem">Stewie</li> </ul> <button>移除下标为0和1的li元素的"listitem"类</button> </body> </html>
运行结果