Html5--dom extension

Source: Internet
Author: User

Element gets

1. Document.getelementsbyclassname (' class ') gets the element through the class name, in the form of an array of classes.

2. Document.queryselector (' div ') gets the element through the CSS selector and matches the 1th element of the match condition.

3. Document.queryselectorall (' selector ') gets the element through the CSS selector, in the form of an array of classes.

Class name Operation

1, Node.classList.add (' class ') Add Class

2. Node.classList.remove (' class ') to remove class

3, Node.classList.toggle (' class ') switch class, have remove, none add

4. Node.classList.contains (' class ') detects if there is a class

Custom properties

1. Custom attribute format: data-*= "", for example data-info= "informant".

2, custom property acquisition: The above example, through node.dataset[' info '] we can get to the custom property value informant

3, Node.dataset is in the form of a class object, when we set the following format, we need to get the hump format correctly: Data-my-name= "Itcast", get node.dataset[' myName ')

Html5--dom extension

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.