当前位置:网站首页>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
边栏推荐
- Jz-065 path in matrix
- Golang uses Mongo driver operation - increase (Advanced)
- Yadali brick playing game based on deep Q-learning
- For the first time in Chinese universities! Unique in the world! Tongji students win international awards
- After the project is pushed to the remote warehouse, Baota webhook automatically publishes it
- Super comprehensive custom deep copy function
- Mark the same items in the Li list in red
- golang正则regexp包使用-05-扩展Expand()、根据正则切割Split()
- Constructor Pattern
- Rapport de la main - d'oeuvre du Conseil de développement de l'aecg air32f103cbt6
猜你喜欢

Sword finger offer 07 Rebuild binary tree

For the first time in Chinese universities! Unique in the world! Tongji students win international awards

Resolve Visio and office365 installation compatibility issues

Highly concurrent optimized Lua + openresty+redis +mysql (multi-level cache implementation) + current limit +canal synchronization solution

免费送书啦!火遍全网的AI给老照片上色,这里有一份详细教程!

李飞飞团队将ViT用在机器人身上,规划推理最高提速512倍,还cue了何恺明的MAE
Introduction to database transactions

到底要不要去外包公司?这篇带你全面了解外包那些坑!

Popular cross domain

Programmer vs hacker thinking | daily anecdotes
随机推荐
golang reverse a slice
Write one file to the marked location of another file
Tensorflow loading cifar10 dataset
揭秘GaussDB(for Redis):全面对比Codis
TensorFlow加载cifar10数据集
How GC determines whether an object can be recycled
VectorDraw Developer Framework 10.1001 Crack
Pytest test framework notes
李飞飞团队将ViT用在机器人身上,规划推理最高提速512倍,还cue了何恺明的MAE
golang使用mongo-driver操作——增(进阶)
Download and installation tutorial of consumer
Sword finger offer 05 Replace spaces
合宙Air32F103CBT6开发板上手报告
sql优化的几种方式
Consumer and producer cases of inter thread synchronization (condition variable)
面试官:你简历上说精通mysql,那你说下聚簇/联合/覆盖索引、回表、索引下推
Don't underestimate the integral mall, its role can be great!
Share the code technology points and software usage of socket multi client communication
Binocular 3D perception (I): preliminary understanding of binocular
Finally, we can figure out whether the binding event in the tag is bracketed or not