- 0133技术站
- 联系QQ:18840023
- QQ交流群

- 微信公众号

jQuery removeClass() 方法
定义和用法
removeClass() 方法从被选元素移除一个或多个类。
注意:如果没有规定参数,则该方法将从被选元素中删除所有类。
语法
$(selector).removeClass(classname,function(index,currentclass))
参数 | 描述 |
classname | 可选。规定要移除的一个或多个类名称。如需移除若干个类,请使用空格分隔类名称 注意: 如果该参数为空,则将移除所有类名称 |
function(index,currentclass) | 可选。返回要移除的一个或多个类名称的函数 index : 返回集合中元素的 index 位置。 currentclass : 返回被选元素的当前类名。 |
<script> $(document).ready(function(){ $("button").click(function(){ $("p").removeClass("intro"); }); }); </script> <style type="text/css"> .intro{ font-size:120%; color:red; } </style> </head> <body> <h1>这是一个标题</h1> <p class="intro">这是一个段落。</p> <p class="intro">这是另一个段落。</p> <button>移除所有P元素的"intro"类</button>
点击 "运行实例" 按钮查看在线实例
效果图:
推荐手册