11, delete before and after the space String.prototype.trim =function() {return This. Replace (/(^[|]) | ([|] $)/g, ""); }2 32. Convert document.getElementById (ID) to $ ("id"))4 5 function$ (ID) {return typeof(id) = = ' String '?document.getElementById (ID): ID}6 73. document.getElementsByTagName (' * ')). Length to see how many Dom elements are in the page;8 94, parseint () will only return the integer part; a complete parseint should look like this: parseint (string, radix), where radix specifies the number of decimal, binary, hexadecimal etc. parseint ("F", 16): 15placing the plus sign in front of a string containing a valid number converts the string to a number, and Null is represented as 0 when used as a number, and False when Boolean. Declares a variable without assigning a value, at which point the value of this variable is undefined. Undefined is used as a number when the type behaves as Nan and is used as a Boolean to behave as false.Ten One5, sorted by JSON property values A varCc=[ -{name: "a", age:30}, -{name: "C", age:24}, the{Name: "B", age:28}, -{Name: "E", age:18}, -{Name: "D", age:38} -].sort (function(Obj1, obj2) { + returnObj1.age-Obj2.age; - }); + for(vari=0;i<cc.length;i++){ AAlert (cc[i][' age ');//show 18,24,28,30,38 in turn at } - -6, merging arrays: - varMergeTo = [4,5,6]; - varMergefrom = [7,8,9]; - Array.prototype.push.apply (mergeto, mergefrom); inMergeTo;//is: [4, 5, 6, 7, 8, 9] - to7, multi-click event Gets the click of which +$ (' #IndexLink, #IndexLink1 '). On (' click ',function(e) { - varId=e.target.id; the //ID is the ID value to be clicked. * } $ Panax Notoginseng8, and then in JavaScript, the following procedure declares a global variable - use declared variables outside of function (whether or not Var is used); the variables are not declared with Var within function; + directly assigned to the window property; A the9, Window.history.forward (1); Prevent the page from receding; + -10, JS Call and aplly usage $ functionPerson (name, age) { $ This. Name =name; - This. Age =Age ; - }; the - functionStudent (name, age, Grade) {WuyiPerson.apply ( This, arguments); the This. grade =grade; - }; Wu varStudent =NewStudent (' Qian ', 21, ' first Grade ')); -Alert (' Name: ' + student.name + ' \ n ' + ' Age: ' + student.age + ' \ n ' + ' Grade: ' +student.grade); About $ //That is, the popular point is: to use student to carry out the contents of the person class, in the person of this class there are this.name and other such statements, - //this creates the property into the student object. - -11, page to bottom automatically load content: A varDIVH = Document.body.scrollheight,top = DOCUMENT.BODY.SCROLLTOP,WINDOWH =Window.screen.availHeight; + if(Top + WINDOWH) >DIVH) { theConsole.log (' The Hell to load the content up. ‘); - } $Console.log (' page body full text High: ' + document.body.scrollHeight + ' page is rolled High: ' + document.body.scrollTop + ' screen usable workspace height: ' + window.scre En.availheight);
JavaScript Tips Summary