当前位置:网站首页>DOM系列之classList属性
DOM系列之classList属性
2022-08-01 15:55:00 【老__L】
classList 属性是 HTML5 新增的一个属性,返回元素的类名。但是 ie10 以上版本支持。该属性用于在元素中添加,移除及切换 CSS 类。有以下方法:
1、添加类
1.1、语法
element.classList.add("类名");
1.2、示例
focus.classList.add("current");
2、移除类
2.1、语法
element.classList.remove("类名");
2.2、示例
focus.classList.remove("current");
3、切换类
3.1、语法
element.classList.toggle("类名");
3.2、示例
focus.classList.toggle("current");
注意以上方法里面,所有类名都不带点
后记
如果你感觉文章不咋地
//(ㄒoㄒ)//,就在评论处留言,作者继续改进;o_O???
如果你觉得该文章有一点点用处,可以给作者点个赞;\\*^o^*//
如果你想要和作者一起进步,可以微信扫描二维码,关注前端老L;~~~///(^v^)\\\~~~
谢谢各位读者们啦(^_^)∠※!!!

边栏推荐
猜你喜欢
随机推荐
商业智能BI业务分析思维:供应链分析 - 什么是牛鞭效应(一)
lombok builder重写
Digicert EV证书签名后出现“证书对于请求用法无效”的解决方案
轮询和长轮询的区别
pytorch中tensor转成图片保存
实习日报-2022-7-30
js to determine whether it is a pc or a mobile terminal (including ipad)
Can MySQL do two-way synchronization of multiple vps?
SyntaxHighlighter带来的字符转义问题
五分钟带你上手ShardingJDBC实现MySQL分库分表
【无标题】
给网站增加离开页面改变网站标题效果
MySQL [create and manage tables]
CSDN配置功能总结
uniapp 获取cookie与携带cookie请求数据
String comparison size in MySQL (date string comparison problem)
Spark: Cluster Computing with Working Sets
urlopen error errno111(英雄联盟报错error)
May 20, 2022 The most complete fish game navigation
A full review of mainstream timed task solutions








