案例:jQuery案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<head>
3
<script type="text/javascript" src="/js/jquery.js"></script>
4
<script type="text/javascript">
5
$(document).ready(function(){
6
  $("button").click(function(){
7
      $('ul li').removeClass(function() {
8
      return 'listitem_' + $(this).index();
9
    });
10
  });
11
});
12
</script>
13
<style type="text/css">
14
.listitem_1, .listitem_3
15
{
16
color:red;
17
}
18
.listitem_0, .listitem_2
19
{
20
color:blue;
21
}
22
</style>
23
</head>
24
25
<body>
26
<h1 id="h1">This is a heading</h1>
27
<ul>
28
<li class="listitem_0">Apple</li>
29
<li class="listitem_1">IBM</li>
30
<li class="listitem_2">Microsoft</li>
31
<li class="listitem_3">Google</li>
32
</ul>
33
<button>删除列表项中的类</button>
34
</body>
35
</html>
36