Attribute
A.setattribute ("Property name", "property value")--set property
A.getsttribute ("Property name")--get property
A.removeattribute ("Property name")--Remove attribute
To illustrate:
Example 1: Do a question, if the input answer is correct then pop up correctly, error pop-up error;
Here in text write a Daan attribute, which stored the value of the answer, click to check the answer when Cheak input and answer whether the same:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">which year was the Republic of China founded? <input type= "Text" daan= "1912" id= "T1" value= ""/> <!--value: Default--><input type= "button" onclick= "Check ( ) "value=" Check the answer "/></form></body>functionCheck () {varA=document.getelementbyid ("T1"); vara1=a.value;<!--define the variable A1 to get the value of the input-varA2=a.getattribute ("Daan");<!--Get Properties--if(a1==A2) {Alert ("Congratulations on your answer!" "); } Else{alert (Fool "); } }</script>
Results:
When you enter the correct answer
When you enter the wrong answer
Example 2: The Consent button, countdown 10 seconds, the consent button becomes available, here is the Action property: Disable, to change the state of the button, when disabled= "disabled" button is not available.
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">#b1 {width:80px; height:30px; } //Set the properties of the button </style>varn=10;varA=document.getelementbyid ("B1");functionBian () {n--; if(n==0) {A.removeattribute ("Disabled"); A.value= "Agree"; return; }Else{A.value= "Consent" ("+n+") "; Window.settimeout ("Bian ()", 1000);} }window.settimeout ("Bian ()", 1000); </script>
Javascrip--dom operation (Property manipulation)