<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><title>Document</title><style></style><Scripttype= "Text/javascript">window.onload= function() {OText1=document.getElementById ('Text1'); varname= 'value'; //alert (Otext1[name]); //alert (otext1[' _name_ '); /*element. GetAttribute (property name) method gets the value of the specified attribute of the specified element custom property is obtained with GetAttribute*/ //Alert (Otext1.getattribute (' value ')); /*element. SetAttribute (property name); method sets the value for the specified element*/ //otext1.setattribute (' value ', ' yes '); /*element. RemoveAttribute (property name); method removes the specified attribute from the specified element do not delete the element with RemoveAttribute property*/ //otext1.removeattribute (' value '); /*1. Use "." and "[]" form cannot manipulate the custom attribute of the element getattribute can manipulate the custom attribute of the element 2. You can get the actual value of the element property IE7 or return the absolute path of the resource */ //alert (otext1._name_); //alert (otext1[' _name_ '); //otext1.removeattribute (' _name_ '); } </Script></Head><BodyID= "Body"> <inputtype= "text"ID= "Text1"value= "ABC"_name_= "M Taste" /></Body></HTML>
JavaScript methods for manipulating element properties