当前位置:网站首页>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;
}
边栏推荐
- MySql存储过程循环的使用分析详解
- Source code installation mavros
- Sd6.23 summary of intensive training
- 优雅书写Controller(参数验证+统一异常处理)
- kubekey2.2.1 kubernetes1.23.7离线包制作+harbor部暑并上传镜像
- codeforces每日5题(均1700)-第二天
- 保持jupyter notebook在终端关闭时的连接方法
- Encryption and decryption of 535 tinyurl
- Jar package background startup and log output
- Kubekey2.2.1 kubernetes1.23.7 offline package production +harbor Department summer and upload image
猜你喜欢
NVIDIA installs the latest graphics card driver
idea怎么使用?
markdown知识轻轻来袭
Detailed analysis on the use of MySQL stored procedure loop
【网络是怎么连接的】第三章 探索集线器,交换机和路由器
[how the network is connected] Chapter 3 explores hubs, switches and routers
MySql存储过程循环的使用分析详解
How QQ opens online customer service
Let Google search your blog
JS merge two 2D arrays and remove the same items (collation)
随机推荐
js两个二维数组合并并去除相同项(整理)
【网络是怎么连接的】第三章 探索集线器,交换机和路由器
Relationship among controller, service and Dao
3H proficient in opencv (VIII) - shape detection
Adobe Premiere Basics - common video effects (corner positioning, mosaic, blur, sharpen, handwriting tools, effect control hierarchy) (16)
SD6.22集训总结
工作流模块Jar包启动报错:liquibase – Waiting for changelog lock….
Error building SqlSession问题
Source code installation mavros
[tcapulusdb knowledge base] tcapulusdb operation and maintenance doc introduction
Sd6.22 summary of intensive training
6.29 simulation summary
Detailed analysis on the use of MySQL stored procedure loop
Adobe Premiere基础-常用的视频特效(裁剪,黑白,剪辑速度,镜像,镜头光晕)(十五)
MySql存储过程循环的使用分析详解
Elegant writing controller (parameter verification + unified exception handling)
美法官裁定,被控掩盖黑客行为的Uber前安全主管必须面对欺诈指控
Adobe Premiere基础-素材嵌套(制作抖音结尾头像动画)(九)
牛客小Bai月赛52 D 环上食虫(尺取+st表)
JWT login authentication