JQuery obtains object Matching Based on attributes, content, and form Element matching _ jquery

Source: Internet
Author: User
JQuery exercises get objects (3)-Matching Based on attributes and content, and matching with form elements that contain id attributes, such as: $ ("span [id]")

The Code is as follows:


AAA

BBB

CCC

DDD

EEE


FFF



If the specified element does not contain the id attribute, for example, $ ("span: not (span [id])") or $ ("span: not ([id])")

The Code is as follows:


AAA

BBB

CCC

DDD

EEE


FFF



Contains the id attribute, such as: $ ("body [id]")

The Code is as follows:


AAA

BBB

CCC

DDD

EEE


FFF



For example, $ ("span [name = 's2']")

The Code is as follows:


AAA

BBB

CCC

DDD

EEE


FFF



Does not match the element value, for example: $ ("span [name! = 'S2'] ")

The Code is as follows:


AAA

BBB

CCC

DDD

EEE


FFF



What does the element value start ?, For example: $ ("span [name ^ ='s ']")

The Code is as follows:


AAA

BBB

CCC

DDD

EEE


FFF



What is the end of the element value ?, For example: $ ("html [name $ = '1']")

The Code is as follows:


AAA

BBB

CCC

DDD

EEE


FFF



Element value inclusion ?, For example: $ ("body [name * = 'X']")

The Code is as follows:


AAA

BBB

CCC

DDD

EEE


FFF



Multiple Attribute conditions, such as (with id and name starting with "D"): $ ("body [id] [name ^ = 'D']")

The Code is as follows:


AAA

BBB

CCC

DDD

EEE


FFF



Search for span: $ ("span: contains ('AB')") containing "AB ')")

The Code is as follows:


ABC

ABC



ABC

ABC




Search for span: $ ("p span: contains ('AB')") containing "AB" from p ')")

The Code is as follows:


ABC

ABC



ABC

ABC




Search for included span: $ ("span: has ('B ')")

The Code is as follows:


ABC

ABC



ABC

ABC




Search for an empty span: $ ("span: empty ")

The Code is as follows:


ABC

ABC



ABC

ABC




Search for non-empty (that is, the parent element) span: $ ("span: parent ")

The Code is as follows:


ABC

ABC



ABC

ABC




: Hidden and: visible correspond to hidden and displayed elements respectively. In the following example, the displayed elements are red and the hidden elements are gray.

The Code is as follows:





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.