博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
dom怎么给元素添加类样式_如何将类添加到DOM元素
阅读量:2504 次
发布时间:2019-05-11

本文共 587 字,大约阅读时间需要 1 分钟。

dom怎么给元素添加类样式

When you have a DOM element reference you can add a new class to it by using the add method:

当您拥有DOM元素引用时,可以使用add方法向其添加新类:

element.classList.add('myclass')

You can remove a class using the remove method:

您可以使用remove方法删除一个类:

element.classList.remove('myclass')

Implementation detail: classList is not an array, but rather it is a collection of type .

实现细节: classList不是数组,而是类型的 。

You can’t directly edit classList because it’s a read-only property. You can however use its methods to change the element classes.

您不能直接编辑classList因为它是只读属性。 但是,您可以使用其方法来更改元素类。

翻译自:

dom怎么给元素添加类样式

转载地址:http://atqgb.baihongyu.com/

你可能感兴趣的文章
TZC Intercommunication System
查看>>
HDU 4571 SPFA+DP
查看>>
centos 创建以日期为名的文件夹
查看>>
Java Timer触发定时器
查看>>
Page Object设计模式
查看>>
程序的基础知识
查看>>
在VIM中使用GDB调试 – 使用vimgdb
查看>>
python爬虫---从零开始(五)pyQuery库
查看>>
POJ2236(KB5-A)
查看>>
Centos MySQL数据库迁移详细步骤
查看>>
2初出茅庐--初级篇2.1
查看>>
新建 WinCE7.0 下的 Silverlight 工程
查看>>
腾讯的张小龙是一个怎样的人?
查看>>
jxl写入excel实现数据导出功能
查看>>
linux文件目录类命令|--cp指令
查看>>
.net MVC 404错误解决方法
查看>>
linux系统目录结构
查看>>
git
查看>>
btn按钮之间事件相互调用
查看>>
Entity Framework 4.3.1 级联删除
查看>>