The jQuery Attribute Contains Word Selector [name~="value"]
is used to select elements that have a specific attribute
with a value containing a given whole word value
,delimited by space.It is case sensitive.
[name~="value"]
selector Syntax$('[attribute~="value"]')
[name~="value"]
selector Examplesselector | test element | result |
---|---|---|
$('li[title~="java"]' |
<li title="jQuery Tutorial"></li> |
not matched |
$('li[title~="java"]' |
<li title="java"></li> |
matched |
$('li[title~="java"]' |
<li title="JAVA"></li> |
not matched(case sensitive) |
$('li[title~="java"]' |
<li title="javac"></li> |
not matched |
$('li[title~="java"]' |
<li title="java-doc"></li> |
not matched |
$('li[title~="java"]' |
<li title="language java"></li> |
matched |
Following is a simple example which find all elements with a title attribute that contains the word java
and hightlight them.
Try now