1. Parameter of the calling function of the function function's declaring function 2. function return value return returns the result to function Id function $id ( ID) {return document.getElementById (ID);} 3. Get focus onfocus onblur lose focus 4. This one's own point is the event caller 5. InnerHTML belongs to the contents of the Box content form value 6. The form automatically gets focus () Select Form Content Selection (); 7. for (var i = 0; I< -; i++) {} traversal 8. for (;;) {} dead Loop 9. getElementById () ID element one 10. getElementsByTagName () Many 1.2 judging user input events normal browser: Oninput Ie 678 supported: Onpropertychange 1.3 Array of arrays is what to do It's used? var num= 10; variables can be used to store things. There can be only one value in a variable. We have 130 people who want to store each of our names and need 130 variables to use variables. You can consider arrays at this time. Combined array: It is a large variable that can store a lot of values. 1.3.1 Declaration array var arr= [1,3,5,7,9]; var arr= newArray (1,3,5); 1.3.2 Use array method: array name [index value]; function name (); The index number starts at 0. 0 1 2 3 4 5 ... var textarr= ["Liu Bei", "Zhuge Liang", "Zhao Yun", "Guan Yu");Console.log (textarr[3]) 1.3.3 array of length array name. length; 1.3.4 times the calendar group thought of the For Traversal Array getElementsByTagName () to get a pseudo-array 1.3.5 case interlaced <script>window.onload = function () {var lis = document.getelementsbytagname ("Li"); Get all the Li//alert (lis.length); for (var i = 0; I<Lis. length; i++) {if (i%2== 0)//Only an even number can be divisible by 2 {Lis[i].style.backgroundcolor= "#eee"; }//Mouse over Li, the current background light lis[i].onmouseover= function () {This.classname= "Current"; } lis[i].onmouseout= function () {This.classname= ""; }}}</script>1.3.6 averaging<Script>vararr= [Ten, -, -, the, the]; functionavg (array) {//Package averaging function varLen=Array.Length; //the length of the array varsum= 0; for(varI=0; I<Len; I++) {sum+=Array[i]; //sum = Sum +array[i]; } returnsum/Len; } //a*=3 a= a*3console.log (avg (arr));</Script>character concatenated + numeric addition character concatenated with 2; "Hello" + "How are you?" "Hello" + 2 "Hello 2" "0" + 10 "010" 10-"2" 8 all input values are character type. Ternary operator trinocular operator unary: a++ b++ +a-a two yuan: a+b a>=b ternary: expression? Result 1: Result 2 is equivalent to if else if the expression result is true, the result 1 is returned if the expression result is false, the result 2 if (3>5) {alert ("one")} else {alert (22)} = = 3>5? Alert (one): alert (All) The King is always luck King Lao Ji 1.4 exclusive thought of exclusivity: first of all, the rest of me.<Script>window.onload= function(){ varBtns=document.getElementsByTagName ("Button"); for(varI=0; I<Btns.length;i++) {Btns[i].onclick= function(){ //clear everyone's class name with for traversal only for(varJ=0; J<btns.length;j++) {Btns[j].classname= ""; } //you're the only one who's left, and it's clicked . This. ClassName= "Damao"; } } }</Script>1.5 variables and attribute variables are independent of the free existence of Miss Miss properties and methods belonging to an object properties and methods Mrs var index = 10; Variable who can use var arr = []; Array arr.index = 20; Custom attributes He can only use alert (Arr.index) in arr;
JS Basic Knowledge 3