小白教程
所有教程
关于
Search
172.71.254.8
172.71.254.8
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Html removeclass”的源代码
本页内容
上一节:
Html_removeattr
下一节:
Html_removeprop
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:removeClass()}}[[Category:jquery ref html|28]] = jQuery removeClass() 方法 = [[jquery ref html|jQuery HTML/CSS 方法]] 从所有的 <p> 元素移除 "intro" 类: <sample title="" desc="" lang="html" hererun="1"> $("button").click(function(){ $("p").removeClass("intro"); }); </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"> </script> <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> </body> </html> </run> == 定义和用法 == removeClass() 方法从被选元素移除一个或多个类。 '''注意:'''如果没有规定参数,则该方法将从被选元素中删除所有类。 == 语法 == <pre> $(selector).removeClass(classname,function(index,currentclass))</pre> {| class="table table-striped table-hover" !width="50%"| 参数 !width="50%"| 描述 |- | classname | 可选。规定要移除的一个或多个类名称。如需移除若干个类,请使用空格分隔类名称。'''注意:''' 如果该参数为空,则将移除所有类名称。 |- | function(index,currentclass) | 可选。返回要移除的一个或多个类名称的函数。 * index - 返回集合中元素的 index 位置。 * currentclass - 返回被选元素的当前类名。 |} == 更多实例 == [[try.php?filename=tryjquery_html_addremoveclass|改变元素的类名]] 如何使用 addClass() 和 removeClass() 来移除一个类名,并添加一个新的类名。 [[try.php?filename=tryjquery_html_removeclass_func|使用函数移除一个类]] 使用函数从被选元素移除一个类。 [[try.php?filename=tryjquery_html_removeclass_several|移除若干个类名]] 如何从被选元素移除若干个类名。 [[jquery ref html|jQuery HTML/CSS 方法]]
返回至“
Html removeclass
”。
上一节:
Html_removeattr
下一节:
Html_removeprop