Get the App
SLTechnology News&Howtos  ›  Development  › 

How html defines methods

Shulou Source: shulou.com Published: 2022-06-01 13:09:18 10月04日 Update

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!

Tags: Articles attributes methods Mars Musk values interests prefixes at the same time objects more friends knowledge editing industry information information channels channels humps Elon Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple NVidia Shulou Tech Info Shulou Technology macOS