HTML5 new Features

Source: Internet
Author: User
Tags shallow copy

New element Selection Method 1, Queryselector: The parameter is a CSS selector, returns the first DOM element that conforms to the selector, and returns no null. ie8+
1 <DivID= "Div1"class= "Div">Div1</Div>2 <DivID= "Div2"class= "Div">Div2</Div>3 <DivID= "Div3"class= "Div">Div3</Div>4 <Script>5     //var oDiv1 = document.queryselector (' #div1 ');6     //var oDiv1 = document.queryselector (' div ');7     varODiv1=Document.queryselector ('. Div');8 9 ODiv1.style.background= 'Red';
2. Queryselectorall: The parameter is a CSS selector; Returns a DOM collection that conforms to the selector, without returning an empty collection. Ie8+3, Getelementsbyclassname: Gets the collection of elements through the class name. ie9+Classlistclasslist: A collection of classes of elements. Classlist related properties and methods: Length: Length add: Adds the corresponding class remove: Removes the corresponding class toggle: Switches class, exists on delete, does not exist Add Item: Access class name According to index contains: judging is Contains the corresponding Classjson to implement object depth or shallow copy
 1  var  OA = {name: ' Hum ' },  2  oB = {},  3  str = ";  4  5  str = 6  oB = Json.parse (str);  7  Console.log (ob.name); //  Hum  8  ob.name = ' Tyx ' ;  9  Console.log (oa.name); //  Hum  

Data customization is simple to use:
1 <DivID= "Div"Data-name= "Hum"Data-real-name= "Tyx">Div</Div>2 <Script>3     varOdiv=Document.queryselector ('#div');4 Console.log (oDiv.dataset.name);//Hum5 Console.log (oDiv.dataset.realName);//Tyx6 </Script>

HTML5 delay load Jsdefer:onload trigger before loading the JS file, only the external JS file to take effect, multiple defer coexistence when the load order cannot be determined. Async: Loading JS files Asynchronously, the order is difficult to guarantee, to load the independent JS. LABJS Library: Dynamically load script files in parallel and manage the order in which the load script files are executed.   History management triggers History Management: 1, page jump 2, change hash 3, Pushstatehash value Change event: Window.onhashchange = function () {};p use of ushstate: Must be run on the server. History.pushstate (data, title, address) Window.onpopstate = function (EV) {Console.log (ev.state)}

HTML5 new Features

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.