CSS/JQuery element selector & amp; and |, logical operations of selector, cssjquery Selector

Source: Internet
Author: User

CSS/JQuery element selector & |, logical operations of selector, cssjquery Selector

When using CSS or JQuery to select an element, we often need to perform the & or | operation on the condition.


| In JQuery or CSS is very common and very simple. It is separated by commas.

Selector1, selector2, selectorN
For example, if you want to select div or span, you can use $ ("div, span") to select elements that meet the conditions.


Most of the & in CSS or JQuery I have seen are implemented using class. I don't know if this is the only method.

. ClassName1.className2. classNameN
For example, if we want to select a div, which must have the class lily and lucy, we can use. lily. lucy to select it.


Special & Operations in JQuery are not limited to class attributes, but more flexible

[Selector1] [selector2] [selectorN]
For example, if we want to select a div, the class of this div is angle, and the id is aty_id, you can use $ ("div [id = 'aty _ id'] [class = 'age']")

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.