How to get custom property values ​​in HTML5

This article shared what to get the content value of the custom property value in HTML5. Xiaobian feels quite practical, so share it with you to do a reference. Let’s take a look at Xiaobian.

Custom Attributes:

In HTML5 we can customize attributes, and its format is DATA – * = “”, for example: data-info = “I am a custom property”, pass Node.DataSet [‘Info’] We can get the custom attribute value.

When we set up as follows, you need to get correctly in hunchprints: Data-my-name = “itcast”, get node.dataset [‘myname’]

   Title     Chi Podcast   Chi Podcast    Window.onLoad = function () {var p = document.QuerySelector ("p"); / * Get custom property value * / / * Use the Camel naming method using the word " : Must use the Camel legal method to obtain values, otherwise it is possible to get the value * / // var value = p.dataset ["SchoolName"]; // Data-schoolname is equivalent to the above code block to look at the same meaning VAR value = p.dataset ["SchoolName"]; // Data-School-name must be the second word. The first letter must be uppercase letters to console.log (value);} 

Thank you for reading! Regarding how to get a custom attribute value in HTML5, share it here, I hope that the above can help everyone, let everyone learn more. If you feel that the article is good, you can share it out to let more people see it!
© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment