JavaScript Learning Notes

Source: Internet
Author: User

JavaScript He is a separate language, usually exists in the HTML file, the browser is JS interpreter script can be placed in the head tag with CSS style, You can also write a commons.js file, import language learning content: Write JS code can be in the HTML file or click on the review element in the browser, in the console to debug the creation of variables: global variables: a = ' asdf ' generally rarely            The part variable (inside the function) var b = ' asdasd ' basic data type number a= age= ' 18 ';            Conversion Type A = parseint (age);                           b= parsefloat (age) String obj.length length Obj.trim () Remove Blank obj.trimleft () obj.trimright) Obj.charat (n) returns               The nth character in a string Obj.concat (value, ...)              Stitching Obj.indexof (Substring,start) sub-sequence position Obj.lastindexof (Substring,start) sub-sequence position Obj.substring (from, to) gets the sub-sequence Obj.slice (start, end) Slice obj based on the index . toLowerCase () uppercase obj.touppercase () lowercase obj.sPlit (delimiter, limit) split Obj.search (regexp) matches from the beginning, returning the first position where the match succeeded (g invalid)              Obj.match (regexp) Global Search, if there is a G in the regular means find all, otherwise only find the first one. Obj.replace (regexp, replacement) replaced, there is g in the regular replaces all, otherwise only the first match, $ number: matches the                                                   n groups of content; $&: Current matching content;                                                   $ ': text at the left of the matched substring; $ ': Text to the right of the matching substring                     $$: Direct Amount $ symbol list (array) obj.length array size Obj.push (ele) trailing element The Obj.pop () tail Gets an element Obj.unshift (Ele) to the head of the Insert element OBJ.SHIF  T () head remove element Obj.splice (start, DeleteCount, value, ...)                         Inserts, deletes, or replaces elements of an array obj.splice (N,0,VAL) inserts an element at the specified position               Obj.splice (N,1,val) specifies the position of the replacement element Obj.splice (n,1) to remove the element at the specified location Obj.slice () slice obj.reverse () Invert obj.join (Sep) joins the array elements together  To build a string Obj.concat (Val,..) Concatenate arrays Obj.sort () array elements to sort dictionary Boolean = = comparison value equal! = No        equals = = = Comparison value and type equality!=== not equal to | | or && and the conditional statement for Loop 1, looping through the list is the index of the element so write 1.            When looping, the element of the loop is index a = [11,22,33,44] for (var item in a) {Console.log (item);            } a = {' K1 ': ' v1 ', ' K2 ': ' V2 '} for (var item in a) {Console.log (item);            } 2. for (Var i=0;i<10;i=i+1) {} This way does not support dictionary a = [11,22,33,44] for (Var i=0;i<a.l ength;i=i+1) {} The creation of the function: Funtion function name (a,b,c) {} Called when the function name (three-way) DOM: File object, used to find the HTML file in the label 1, find the tag to get a single element document.ge Telementbyid (' I1 ') gets multiple elements (return list) document.getelementsbyname (' Asda ') gets multiple elements (return list) Document.getelementsby          TagName (' div ') gets multiple elements (return list) Document.getelementsbyclassname (' C1 ') indirectly looking for: parentnode                  Parent node ChildNodes//All child nodes FirstChild//first child node LastChild//Last child node nextSibling//Next sibling node previoussibling//prev                  Sibling node parentelement//parent node tag element children//ALL child tags Firstelementchild//First child tag element lastelementchild//Last child tag element Nextelementt            Sibling//Next sibling tag element previouselementsibling//Previous sibling tag element 2, action tag get content inside tag          tags. innerText  B.classname B.classname Direct overall operation B.classname.add (style name) Add Style B.classname.remov                        E (style name) Delete style C, CheckBox get Value CheckBox object. Checked Sets the checkbox object. Checked = Truecss Supplement:-position-background-hover-overflow-z- index-opacity Example: Placing an icon to the right of the input box javascript: local variable var basic data type: Numeric string array Dictionary Boolean Fo        R loop Conditional statement = = = = = = = = =!== | | Definition of && functions: function func () {...} Dom looking for a tag-just look for $ (' #id ') $ ('. C1 '). Siblings ()-Introduction find operation: InnerText Checkbox:che            cked className classlist Event: <div onclick= ' function (123) ' ></div> <script>        。。。。  </script> Timer setinterval (' function () ', 4000) Other: alert () Console.log () Example: Visit the Guide  Multi-modal dialog left menu back to top 

JavaScript Learning Notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.