Blogger Information
Blog 81
fans 1
comment 0
visits 124111
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
js 如何获取自定义的标签属性 dataset
有什么是忘不了的的博客
Original
925 people have browsed it

现获取对象自定义对象:

<div id = 'data-test' data-my-age = "23"></div>
  <script>
    let age = document.getElementById("data-test")
    alert(age.dataset.myAge)  //dataset属性是用来获取对象上的自定义的属性值
   </script>

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post