[HTML5 and CSS3 Basics] selector querySelector and querySelectorAll, css3queryselector

Source: Internet
Author: User

[HTML5 and CSS3 Basics] selector querySelector and querySelectorAll, css3queryselector

HTML5 provides two selector functions similar to JQuery for searching elements: querySelector and querySelectorAll. The former searches for elements and returns the first element, while the latter searches for elements and returns a NodeList, it contains all elements that match the selector.
Usage:
Var buttons = document. querySelectorAll (". menu ");
The preceding statement finds the elements whose class is menu and whose label is a, forms an array, and assigns values to buttons. Then, you can use the array to use the searched elements.
The parameters of the above two methods must use the selection Syntax of CSS3. For the selection Syntax of CSS3, refer to this address: CSS selector reference manual.

The preceding example uses the following selection Syntax:

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.