Application of the model in the actual case:
Alternating colors:
<!DOCTYPE HTML><HTML><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"><title>Untitled Document</title><Script>/*var i = 0;i++;if (i = = 5) {i = 0;} i%=5;*/window.onload= function (){ varALi=document.getElementsByTagName ('Li'); vararr= [ 'Red', 'Yellow', 'Blue' ]; for( varI=0; I<ali.length; I++) {Ali[i].index=i; Ali[i].style.background=Arr[i%Arr.length]; //If this is just ali[i].style.background = Arr[i], then only 3 lines of Li's background for the loop will be finished, after the mold can loop to get 0,1,2, such results, and then continue to add style to Li. Ali[i].onmouseover= function (){ This. Style.background= 'Gray'; }; Ali[i].onmouseout= function (){ This. Style.background=arr[ This. Index%Arr.length]; }; }};</Script><style>Li{Height:24px;Margin-bottom:3px;List-style:None; }</style></Head><Body><ulID= "UL1"> <Li></Li> <Li></Li> <Li></Li> <Li></Li> <Li></Li> <Li></Li> <Li></Li> <Li></Li> <Li></Li> <Li></Li> <Li></Li> <Li></Li> <Li></Li></ul></Body></HTML>
The use of inverse operators in real-world cases:
<!DOCTYPE HTML><HTML><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"><title>Untitled Document</title><Script>window.onload= function (){ varAINP=document.getElementsByTagName ('input'); //ainp[1].checked = false; //ainp[2].checked = true;ainp[0].onclick= function (){ for( varI=1; I<ainp.length; I++) {ainp[i].checked= !ainp[i].checked;///*if (ainp[i].checked) {ainp[i].checked = false; } else {ainp[i].checked = true; } */ } };};</Script></Head><Body><inputtype= "button"value= "Reverse Selection" /><ul> <Li><inputtype= "checkbox"checked/></Li> <Li><inputtype= "checkbox" /></Li> <Li><inputtype= "checkbox"checked/></Li> <Li><inputtype= "checkbox" /></Li> <Li><inputtype= "checkbox" /></Li></ul></Body></HTML>
Operator 1-js Learning Note 2015-6-13 (56th day)