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: