This article describes how JS operates HTML custom attributes. Share it for your reference. The details are as follows:
The HTML code is as follows (where displayName is a custom property):
Copy the code code as follows:<input type="text" id="txtBox" displayName="123456" />
Get custom attribute values:
The code copy is as follows: document.getElementById("txtBox").getAttribute("displayName");
document.getElementById("txtInput").attributes["displayName"].nodeValue
Set custom attribute values:
The code copy is as follows: document.all.txtBox.setAttribute("displayName","123456");
document.getElementById("txtInput").attributes["displayName"].nodeValue = "123456"
I hope this article will be helpful to everyone's JavaScript programming.