当前位置:网站首页>JS add custom attributes to elements
JS add custom attributes to elements
2022-06-25 15:52:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
Add custom attributes to elements
obj.setAttribute('attr_name','attr_value');
// for example obj.setAttribute('class','snow-container')Add to element class Three methods of attribute
document.getElementsByTagName('body')[0].className = 'snow-container'; // Set as new
document.getElementsByTagName('body')[0].className += 'snow-container'; // Add this after the original
document.getElementsByTagName('body')[0].classList.add("snow-container"); // Equivalent to the first Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/152101.html Link to the original text :https://javaforall.cn
边栏推荐
- Inter thread synchronization semaphore control
- 剑指 Offer 05. 替换空格
- Popular cross domain
- The release of autok3s v0.5.0 continues to be simple and friendly
- JS notes
- 镁光256Gb NAND Flash芯片介绍
- Golang open source streaming media audio and video network transmission service -lal
- 解析数仓lazyagg查询重写优化
- Client development (electron) system level API usage
- Sword finger offer 05 Replace spaces
猜你喜欢

Programmer vs hacker thinking | daily anecdotes

基于神经标签搜索,中科院&微软亚研零样本多语言抽取式摘要入选ACL 2022

合宙Air32F103CBT6開發板上手報告
Prototype mode

剑指 Offer 05. 替换空格

Don't underestimate the integral mall, its role can be great!

分享自己平时使用的socket多客户端通信的代码技术点和软件使用

Download and installation tutorial of consumer
Consumer and producer cases of inter thread synchronization (condition variable)

LeCun预言AGI:大模型和强化学习都是斜道!我的「世界模型」才是新路
随机推荐
解析数仓lazyagg查询重写优化
Talk about the creation process of JVM objects
Golang uses Mongo driver operation - increase (Advanced)
李飞飞团队将ViT用在机器人身上,规划推理最高提速512倍,还cue了何恺明的MAE
什么是NFT数字藏品?
B站付费视频使up主掉粉过万
Introduction to database transactions
Source code analysis of nine routing strategies for distributed task scheduling platform XXL job
Tensorflow loading cifar10 dataset
Sleep formula: how to cure bad sleep?
AutoK3s v0.5.0 发布 延续简约和友好
Take you to the open source project of smart home: the preliminary configuration of zhiting home cloud and home assistant+ homebridge
NFT元宇宙发展能做什么?
Startup and shutdown of appium service
Es data synchronization mode
Cloning and importing DOM nodes
Ten routing strategies for distributed task scheduling platform XXL job
Why is it said that restarting can solve 90% of the problems
剑指 Offer 10- I. 斐波那契数列
MT60B1G16HC-48B:A美光内存颗粒FBGA代码D8BNK[通俗易懂]