<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">pre{color:green;padding:10px 15px;background: #f0f0f0; border:1px dotted #333;font:12px/1.5 Courier New;} Span{color: #999;}</style>gt; vari = Iresult = 0functionsum () { for(vari = 0; i < arguments.length; i++) {Iresult+=Arguments[i]}returnIresult}<span>//Applications </span>Alert (sum (1,2,3,4,5,6,7,8,9,10)) <span>//Output 55</span></script></pre><script type= "Text/javascript" >vari = Iresult = 0functionsum () { for(vari = 0; i < arguments.length; i++) {Iresult+=Arguments[i]}returnIresult}//ApplicationAlert (SUM (1,2,3,4,5,6,7,8,9,10))</script></body>CSS functions--set/Read properties of an object
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">div{width:400px;height:200px;background: #fef4eb; border:1px solid #f60; margin:0Auto;} Input{border:0;color: #fff; cursor:pointer;font-weight:700;background: #f60;p adding:2px 4px;margin:10px 0 010px;}</style><script type= "Text/javascript" >functioncss (obj, attr, value) {Switch(arguments.length) { Case2: if(typeofARGUMENTS[1] = = "Object") { //two parameters, if the second argument is an object, bulk set properties for(varIinchattr) Obj.style[i] =Attr[i]}Else { //two parameters, if the second argument is a string, read the property value returnObj.currentstyle? OBJ.CURRENTSTYLE[ATTR]: getComputedStyle (obj,NULL) [attr]} Break; Case3: //three parameters, single set propertyOBJ.STYLE[ATTR] =value; Break; default: Alert ("Parameter Error! ")}}window.onload=function (){ varOBox = document.getElementById ("box"); varAinput = obox.getelementsbytagname ("Input"); //First button click eventAinput[0].onclick =function () { //two parameters, the second argument is a string, the property value is readAlert ("width:" + css (oBox, "width") + "\nheight:" + CSS (oBox, "height") + "\nbackground-color:" + CSS (OBox, "background") Color ")) }; //second button click ThingAinput[1].onclick =function () { //two parameters, second parameter is Object, property batch setCSS (OBox, {width: "330px", Height: "100px", BorderColor: "#0084ff", BackgroundColor: "#eff8ff"}); //three parameters, single set of properties for(i = 0; i < ainput.length; i++) css (Ainput[i], "BackgroundColor", "#0084ff") } //Third button click eventAinput[2].onclick =function () { //two parameters, second parameter is Object, property batch setCSS (OBox, {width: "400px", Height: "200px", BorderColor: "#f60", BackgroundColor: "#fef4eb"}); //three parameters, single set of properties for(i = 0; i < ainput.length; i++) css (Ainput[i], "BackgroundColor", "#f60") }};</script>The current input box is highlighted
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">Body,form,h2,p,input{margin:0;padding:0;} Body{color: #4f4f4f; font:14px/1.5 \5fae\8f6f\96c5\9ed1;} Form{width:400px;background: #fef4eb, border:2px solid #f60;p adding-bottom:10px;overflow:hidden;zoom:1; margin:10px Auto;} Form h2{color: #fe791e; font-size:16px;background: #ffebd7; border-bottom:2px solid #f60;p adding:5px 10px;} Form p{float: left;clear:both;width:100%;height:31px;margin-top:10px;line-height:31px;} Form Label,form input{float: Left;} Form Label{width:100px;height:31px;text-Align:right;} Form Input{border:0;font-family:\5fae\8f6f\96c5\9ed1;background:url (Img/input.png) no-repeat;} Form. F-text,form. f-text-high{width:203px;height:31px;padding-left:5px;line-height:31px;} form. F-text-high{background-position:0-31px;} form. F-btn{color: #fff; Width:104px;height:31px;cursor:pointer;font-size:16px;background: #f60; line-height:31px;border-radius:5px;}</style><script type= "Text/javascript" >window.onload=function (){ varAinput = document.getElementsByTagName ("Input"); vari = 0; for(i = 0; i < ainput.length-1; i++) {Ainput[i].onfocus=function () { This. ClassName = "F-text-high" }; Ainput[i].onblur=function () { This. ClassName = "F-text" } }};</script>Agruments application--Find out the summation &&css function of function parameters--set/Read properties of Object && current input box highlight