The difference between the jquery id selector and the class selector is often discussed.

Source: Internet
Author: User

The difference between the jquery id selector and the class selector is often discussed.

Example:

<! DOCTYPE html> 

The size () method returns the number of DOM objects.

<! DOCTYPE html> 

That is:Id is unique. Even if multiple elements with the same id exist, the jquery selector can only obtain one of them. Therefore: to set the id action in jquery, the id can only appear once on the page.

For CSS Styles, you can select all DOM objects with id = box on the page:

#box {  color: red;};

The Writing Method of the jQuery selector is very similar to that of the CSS selector, but the functions are different:

CSS adds a single style after finding an element, while jquery adds action behavior.

The difference between the jquery id selector and the class selector is the full content shared by the editor. I hope you can give us a reference and support the help house.

Related Article

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.