How html defines methods
This article mainly introduces how to define the method of html, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor with you to understand.
Define
H5 provides us with the prefix "data-" to define the required attributes to set custom attributes.
Get
Use the H5 custom property object dataset to get the
Let box1 = document.getElementById ('box1'); let box2 = document.getElementById (' box2'); box1.dataset.name / / Muskbox2.dataset.fullName / / Elon Musk (hump) box1.getAttribute ('data-name') / / Muskbox2.getAttribute (' data-full-name') / / Elon Musk
Set up
Let box1 = document.getElementById ('box1'); let box2 = document.getElementById (' box2') Box1.dataset.name = 'Musk' box2.setAttribute ('data-full-name',' Elon Musk') Thank you for reading this article carefully. I hope the article "how to define html" shared by the editor will be helpful to you. At the same time, I hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!