Action Properties:
Object. SetAttribute (' attribute name ', ' value '); -Add attributes
Object. getattribute (' attribute name '); -Gets the property value, if no this property, then returns null
<! DOCTYPE html>"http://www.w3.org/1999/xhtml">"Content-type"Content="text/html; Charset=utf-8"/> <title></title> <style type="Text/css">. div1 {width:100px; height:50px; float: Left; Margin-right:10px; } </style>class="Div1"Dd="1"></div> <divclass="Div1"Dd="1"></div> <divclass="Div1"Dd="0"></div> <divclass="Div1"Dd="0"></div> <divclass="Div1"></div> <divclass="Div1"></div></body>"Text/javascript">varAA = Document.getelementsbyclassname ("Div1"); for(vari =0; i < aa.length; i++) { if(Aa[i].getattribute ("DD") =="1") Aa[i].style.backgroundcolor="Green"; Else if(Aa[i].getattribute ("DD") =="0") Aa[i].style.backgroundcolor="Yellow"; ElseAa[i].style.backgroundcolor="Red"; }</script>
Object. removeattribute (' attribute name '); -Remove attributes
<! DOCTYPE html>"http://www.w3.org/1999/xhtml">"Content-type"Content="text/html; Charset=utf-8"/> <title></title>"Button"Value="Button 111"Id="DD1"/> <input type="Button"Value="Button 222"Id="DD2"/></body>"Text/javascript">varAAA = document.getElementById ("DD1"); varBBB = document.getElementById ("DD2"); //Click events for button 111Aaa.onclick =function () {//Button 111 Adding a property is not available This. SetAttribute ("Disabled","Disabled"); //gets the value of the property value in AAA varCCC = This. getattribute ("value"); Alert (CCC); } //BBB's Click eventBbb.onclick =function () {//Remove the AAA disabled propertyAaa.removeattribute ("Disabled"); }</script>
2. Verify 5+5=?
<! DOCTYPE html>"http://www.w3.org/1999/xhtml">"Content-type"Content="text/html; Charset=utf-8"/> <title></title>5+5= <input type="text"Id="DD1"Data="Ten"/> <input type="Button"Id="DD2"Value="Validation"/></body>"Text/javascript">varAAA = document.getElementById ("DD1"); varBBB = document.getElementById ("DD2"); //Click events for button 111//BBB's Click eventBbb.onclick =function () {vartxt = Aaa.getattribute ("Data"); if(txt = =aaa.value) Alert ("correct"); ElseAlert ("Stupid"); }</script>
Timer:
Window.settimeout (function () {}, time interval milliseconds);
-Time bomb, deferred execution, only once
Window.setinterval (function () {}, Interval of time milliseconds);
-infinite loops, each cycle has a time interval, generally not less than 20 milliseconds
-It has a return value, you can use a variable to receive the Timer object
Window.clearinterval (the Timer object to be closed);
Once this code is executed, the execution of this timer object is stopped immediately.
Object. offsetwidth
js--Action Properties