This article mainly introduces how to operate HTML custom attributes in javascript. it analyzes the settings of custom attributes in html and the corresponding javascript operation skills in the form of examples, which is of great practical value, for more information about how to operate HTML custom attributes in JavaScript, see the following example. Share it with you for your reference. The details are as follows:
The HTML code is as follows (displayName is a custom attribute ):
The code is as follows:
Get Custom property values:
The code is as follows:
Document. getElementById ("txtBox"). getAttribute ("displayName ");
Document. getElementById ("txtInput"). attributes ["displayName"]. nodeValue
Set Custom property values:
The code is as follows:
Document.all.txt Box. setAttribute ("displayName", "123456 ");
Document. getElementById ("txtInput"). attributes ["displayName"]. nodeValue = "123456"
I hope this article will help you design javascript programs.