Home > Web Front-end > JS Tutorial > Use javascript to add control custom attribute parsing_javascript skills

Use javascript to add control custom attribute parsing_javascript skills

WBOY
Release: 2016-05-16 17:12:30
Original
1363 people have browsed it

As mentioned before, adding custom attributes to HTML elements is done manually in the HTML control. In fact, it can be added dynamically in javascript: If there is a text box:

Copy code The code is as follows:



If you want to add the idvalue attribute (the value is "custom value"), you can write this in javascript:
Copy Code The code is as follows:

var txt = document.getElementById("txtInput");
txt.setAttribute("idvalue","custom value" );

The first parameter in setAttribute specifies the name of the custom attribute, and the second parameter is the initial value

The code is as follows:

Copy codeThe code is as follows:



; Add control custom attributes with javascript
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template