JQuery Attribute Manipulation
When I browse the web for information about jQuery and I got a jquery cheat sheet. There I am very confused about how to use the following condition. Help me.
[attribute|=val] [attribute*=val] [attribute~=val] [attribute$=val] [attribute=val] [attribute!=val] [attribute^=val] [attribute] [attribute1=val1] [attribute2=val2]
What are the functions of these special characters *, ~, $,!, ^? Many thanks.
a source to share
Refer to attribute selectors :
-
=
: equals -
^
: starts with -
$
: ends with -
!
: not equal -
*
: contains -
~
: contains word -
|
: contains a prefix -
[name]
: has an attributename
Your last example can mean one of two things depending on whether it has a gap in between or not:
-
[attr1=foo][attr2=bar]
means to find elements that have an attributeattr1
with a valuefoo
andattr2
with a valuebar
; but -
[attr1=foo] [attr2=bar]
means to find elementsattr1
with a value attributefoo
that have descendantsattr2
with a value attributebar
.
Space here makes an important semantic difference in expression.
a source to share