W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<html> <head> <script type="text/javascript" src="/jquery/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $('ul li').removeClass(function() { return 'listitem_' + $(this).index(); }); }); }); </script> <style type="text/css"> .listitem_1, .listitem_3 { color:red; } .listitem_0, .listitem_2 { color:blue; } </style> </head> <body> <h1 id="h1">This is a heading</h1> <ul> <li class="listitem_0">Apple</li> <li class="listitem_1">IBM</li> <li class="listitem_2">Microsoft</li> <li class="listitem_3">Google</li> </ul> <button>删除列表项中的类</button> </body> </html>