当前位置:网站首页>[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;
}
边栏推荐
- PHP通过第三方插件爬取数据
- Handsontable数据网格组件
- 【动态规划】路径dp:931. Minimum Falling Path Sum
- PHP array splicing MySQL in statement
- What will Web3 bring in the future?
- 7-2 拼题A打卡奖励 dp
- 一站式洞察行业热点,飞瓜数据B站新功能「流量大盘」上线!
- 3dsmax plug-in development traversal node object and object acquisition and inode transformation matrix description
- 工作6年,来盘点一下职场人混迹职场的黄金法则
- 使用 C# 创造 ASCII 艺术
猜你喜欢

3500字归纳总结:一名合格的软件测试工程师需要掌握的技能大全

医疗HIS行业短信发送解决方案
![[fundamentals of wireless communication-14]: illustrated mobile communication technology and application development-2-the first generation mobile analog communication big brother](/img/fa/f9bad44147ba9af21183b7bd630e32.png)
[fundamentals of wireless communication-14]: illustrated mobile communication technology and application development-2-the first generation mobile analog communication big brother

Digital IC design process summary

Basic knowledge II - Basic definitions related to sta

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

正向代理和反向代理快速理解

Selenium经典面试题-多窗口切换解决方案
![[problem handled] -nvidia SMI command cannot obtain the GPU process number of its own container and the external GPU process number](/img/51/e48e222c14f4a4e9f2be91a677033f.png)
[problem handled] -nvidia SMI command cannot obtain the GPU process number of its own container and the external GPU process number

测试必备工具—Postman实战教程
随机推荐
Try new possibilities
Use of laravel carbon time processing class
New opportunities for vr/ar brought by metauniverse
数学知识:满足条件的01序列—求组合数
微生物安全与健康,什么是生物处理?
Log4j2 threadcontext log link tracking
远程办公如何保持高效协同,实现项目稳定增长 |社区征文
亲测有效,快速创建JMeter桌面快捷方式
Handsontable數據網格組件
"Open math input panel" in MathType editing in win11 is gray and cannot be edited
思特奇加入openGauss开源社区,共同推动数据库产业生态发展
Institute of Microbiology, commonly used biochemical reactions in microbiological testing
laravel 事件 & 订阅
Qt5 mvc: revealing the secrets of data visualization
元宇宙为 VR/AR 带来的新机会
3dsmax plug-in development traversal node object and object acquisition and inode transformation matrix description
数学知识:求组合数 III—求组合数
如何选择券商?另外,手机开户安全么?
Some items of OCR
1500w播放下还藏着什么热点?B站2个未来趋势你不得错过