当前位置:网站首页>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;
}
边栏推荐
- [tcapulusdb knowledge base] tcapulusdb operation and maintenance doc introduction
- 如何在树莓派上使用OAK相机?
- MaxCompute Studio
- Adobe Premiere foundation - time remapping (10)
- idea怎么使用?
- Mysql database daily backup and scheduled cleanup script
- Weibo comments on high-performance and high availability architecture design (module 5 of architecture practice camp)
- jdbc_相關代碼
- 【TcaplusDB知识库】TcaplusDB单据受理-创建游戏区介绍
- markdown常用字体
猜你喜欢

Request header field xxxx is not allowed by Access-Control-Allow-Headers in preflight response问题

Adobe Premiere Basics - common video effects (cropping, black and white, clip speed, mirroring, lens halo) (XV)

Error building SqlSession问题

Niuke small Bai monthly race 52 D ring insectivorous (feet +st table)

美法官裁定,被控掩盖黑客行为的Uber前安全主管必须面对欺诈指控

Anaconda安装并配置jupyter notebook远程

The soft youth under the blessing of devcloud makes education "smart" in the cloud

Application and practice of DDD in domestic hotel transaction -- Theory

jdbc认识上手

MySQL -connector/j driver download
随机推荐
JDBC Codes connexes
JS merge two 2D arrays and remove the same items (collation)
QQ如何开通在线客服
MaxCompute Studio
源码安装MAVROS
Shell basic syntax -- process control
【TcaplusDB知识库】TcaplusDB系统用户组介绍
Sd6.22 summary of intensive training
Codeworks 5 questions per day (1700 for each) - the next day
Adobe Premiere Basics - common video effects (corner positioning, mosaic, blur, sharpen, handwriting tools, effect control hierarchy) (16)
牛客小Bai月赛52 D 环上食虫(尺取+st表)
MySQL数据库每日备份并定时清理脚本
优雅书写Controller(参数验证+统一异常处理)
剑指 Offer 34. 二叉树中和为某一值的路径-dfs法
Adobe Premiere foundation - batch material import sequence - variable speed and rewind (recall) - continuous action shot switching - subtitle requirements (13)
Proxmox VE Install 7.2
Adobe Premiere基础-不透明度(蒙版)(十一)
Precondition end of script headers or end of script output before headers
Elegant writing controller (parameter verification + unified exception handling)
mysql -connector/j驱动下载