当前位置:网站首页>Data-* attribute usage
Data-* attribute usage
2022-06-29 18:27:00 【weixin_ forty-two million one hundred and seventy-eight thousan】
data-* Attribute usage
data-* Attributes are global attributes , Is a class called Custom data properties Properties of , It can make us in all html The ability to embed custom data attributes on elements , And through the script HTML and DOM Realize proprietary data exchange between .
Such as :<p class="test" data-name=" Zhang San " data-age="25"></p>
data-* Of * Can be named as you like , But the following must be observed Naming rules :
1、 Can't use xml start , Whether it's uppercase or lowercase
2、 The name cannot contain any semicolons
3、 Can not contain A-Z Capital
obtain data-* The method of value
Method 1 :
document.getElementsByClassName("test")[0].dataset; // Will return to all data-* The value of the json object
Method 2 :
document.getElementsByClassName("test")[0].getAttribute("data-name"); // Will return to all data-name Value , It can also be passed setAttribute To set its value
stay css Can be accessed through the following methods :
.test[data-name=" Zhang San "] {
font-size: 100px;
}
边栏推荐
- Adobe Premiere Basics - common video effects (cropping, black and white, clip speed, mirroring, lens halo) (XV)
- 2022.6.29-----leetcode. five hundred and thirty-five
- EasyCVR部署服务器集群时,出现一台在线一台不在线是什么原因?
- JWT login authentication
- 软件测试——基础理论知识你都不一定看得懂
- 工作流模块Jar包启动报错:liquibase – Waiting for changelog lock….
- 国内酒店交易DDD应用与实践——理论篇
- How QQ opens online customer service
- C comparison of the performance of dapper efcore sqlsugar FreeSQL hisql sqlserver, an ORM framework at home and abroad
- 535. encryption and decryption of tinyurl / Jianzhi offer II 103 Minimum number of coins
猜你喜欢

Us judge ruled that the former security director of Uber accused of covering up hacking must face fraud charges

如何将OAK相机当做网络摄像头使用?

garbage collector

Adobe Premiere基础-编辑素材文件常规操作(脱机文件,替换素材,素材标签和编组,素材启用,便捷调节不透明度,项目打包)(十七)

Request header field XXXX is not allowed by access control allow headers in preflight response

Anaconda安装并配置jupyter notebook远程

jdbc_ Related codes

Adobe Premiere基础-常用的视频特效(边角定位,马赛克,模糊,锐化,手写工具,效果控件层级顺序)(十六)

JDBC Codes connexes

How to use idea?
随机推荐
RocketMQ的tag过滤和sql过滤
【TcaplusDB知识库】TcaplusDB运维单据介绍
剑指 Offer 34. 二叉树中和为某一值的路径-dfs法
SD6.24集训总结
jdbc_相关代码
SD6.22集训总结
You can do sideline work
Application and practice of DDD in domestic hotel transaction -- Theory
When easycvr deploys a server cluster, what is the reason why one is online and the other is offline?
6.29模拟赛总结
JS merge two 2D arrays and remove the same items (collation)
面试题 10.10. 数字流的秩
Xiaobai yuesai 51 supplement e g f
PostgreSQL database system table
How do I add SmartArt to slides in PowerPoint?
shell教程之循环语句for,while,until用法
jdbc_相關代碼
3H proficient in opencv (V) - perspective transformation
Goldfish rhca memoirs: do447 building advanced job workflow -- using fact cache to improve performance
The soft youth under the blessing of devcloud makes education "smart" in the cloud