The ID selector of the jquery selector

Source: Internet
Author: User

Any operation of the page requires the support of the node, and the developer can quickly and efficiently find the specified node is also a focus in front-end development. jquery provides a range of selectors to help developers achieve this goal, allowing developers to deal with complex selection processes and performance optimizations less, and more focused on the writing of business logic.

jquery almost supports the writing of mainstream CSS1~CSS3 selectors, and we start with the simplest and most commonly used ones.

ID selector: An ID to find, that is, the id attribute of the element.

$ (' #id ')

The ID selector is also the basic selector, and jquery uses the JavaScript function document.getElementById () to handle the acquisition of the ID. Native syntax support is always very efficient, so altogether consider using this selector if you can use the ID if you are able to manipulate the DOM.

It is worth noting that:

IDs are unique, and each ID value can be used only once in a page. If more than one element is assigned the same ID, only the first DOM element of the selected collection will match the ID. But this behavior should not occur, there are more than one element of the page using the same ID is invalid.

The ID selector of the jquery selector

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.