当前位置:网站首页>[JS adds attributes to elements: setAttribute; classlist.remove; classlist.add;]
[JS adds attributes to elements: setAttribute; classlist.remove; classlist.add;]
2022-07-01 01:41:00 【Min_ Fox】
- Get the current element first
html
<img id="zi" class="zi" src="/src/image/w.png">
js
const zi = document.getElementById("zi");
- modify img Elemental src attribute
Use setAttribute To set properties .
js
zi.setAttribute("src", this.key);
- Add to element class
Use classList.remove To delete class、classList.add To add new class, Can be used to modify the style .
js
// Delete class
zi.classList.remove("update-file-block");
// increase class
zi.classList.add("update-file-none");
css
.update-file-block {
display: inline-block;
}
.update-file-none {
display: none !important;
}
边栏推荐
- 面对产业互联网的时候,甚至还用消费互联网的方式和方法去落地和实践产业互联网
- [Qt5 basics] random number display
- Matlab farthest point sampling (FPS improved version)
- Institute of Microbiology, commonly used biochemical reactions in microbiological testing
- php将二维数组元素转为键值对
- 正向代理和反向代理快速理解
- 数据探索电商平台用户行为流失分析
- zabbix如何配置告警短信?(预警短信通知设置流程)
- 【Qt5-基础篇】随机数显示屏展示
- 微研所,微生物检验中常用的生化反应
猜你喜欢

哪有什么未来可期,不过是打工人临死前最后的幻想罢了

Use of typora

使用 C# 创造 ASCII 艺术

医疗HIS行业短信发送解决方案

3500 word summary: a complete set of skills that a qualified software testing engineer needs to master

微生物健康,食品微生物检测为什么很重要
![[无线通信基础-14]:图解移动通信技术与应用发展-2-第一代移动模拟通信大哥大](/img/fa/f9bad44147ba9af21183b7bd630e32.png)
[无线通信基础-14]:图解移动通信技术与应用发展-2-第一代移动模拟通信大哥大

"Open math input panel" in MathType editing in win11 is gray and cannot be edited

gin 配置文件

Lecun, a Turing Award winner, pointed out that the future of AI lies in self-learning, and the company has embarked on the journey
随机推荐
php将二维数组元素转为键值对
数据探索电商平台用户行为流失分析
孙宇晨接受瑞士媒体Bilan采访:熊市不会持续太久
视频教程 | 长安链推出系列视频教程合集(入门)
Mysql database foundation: process control
【Qt5-基础篇_1】从0开始,德天老师和你一起学习——窗口简介
面对产业互联网的时候,甚至还用消费互联网的方式和方法去落地和实践产业互联网
Thinking brought by strictmode -strictmode principle (5)
[Qt5 tab] tab label and content hierarchical analysis
如何选择券商?另外,手机开户安全么?
Applet Custom Grid
Laravel+redis generates an order number - automatically increase from 1 on the same day
org.redisson.client.RedisResponseTimeoutException: Redis server response timeout (3000 ms)错误解决
【Qt5-基础篇】随机数显示屏展示
【JS给元素添加属性:setAttribute;classList.remove;classList.add;】
短信在企业中的应用有哪些?
1500w播放下还藏着什么热点?B站2个未来趋势你不得错过
Some items of OCR
Selenium经典面试题-多窗口切换解决方案
Unknown database connection database error