jQuery Tutorial Tutorials - jQuery [name~="value"] selector

jQuery [name~="value"] selector

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.

jQuery [name~="value"] selector Syntax

$('[attribute~="value"]')

jQuery [name~="value"] selector Examples

selector 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

Date:2019-08-17 23:32:59 From:www.Lautturi.com author:Lautturi