Wednesday, June 13, 2007

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>
 
Blogger Template Layout Design by [ METAMUSE ] : Code Name Gadget 1.1 Power By freecode-frecode.blogger.com & blogger.com Programming Blogs - BlogCatalog Blog Directory