javascript create attribute method
createAttribute() Syntax, Parameters and Note
Creates an attribute node.
It also works with user-defined XML elements, allowing for the creation of
custom attributes.
Syntax:
document.createAttribute(param1)
Parameters:
param1 Required; the name of the attribute.
createAttribute() example code
<html>
<body>
<script language="JavaScript">
function function1() {
var newAttr = document.createAttribute("readOnly");
newAttr.nodeValue = "true"
document.getElementById("mvname").setAttributeNode(newAttr);
}
</script>
<input type="text" id="mvname" value="create Attribute test" size="40"/>
<input type="button" value="Add readOnly attribute to textbox" onclick="function1();">
</body>
</html>