Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this operator ~= mean in jquery? [closed]

I saw this $("a[rel~='single']") somewhere. What is the operator ~= in jquery?

Does anyone know where the documentation for that is?

Thanks in advance.

like image 293
tipsywacky Avatar asked Sep 13 '12 08:09

tipsywacky


2 Answers

When the equal sign in an attribute selector is preceded by a tilde ( ~ ), that means that the selector will match if the value listed is any one of the space-separated values of the given attribute. So the first rule's selector, *[class~="urgent"] , will match any of the following elements:

<p class="very urgent really">
<table class="urgent">
<ul class="not urgent">
<pre class="not terribly urgent but still worth knowing">

Source: http://meyerweb.com/eric/articles/webrev/200008b.html


jQuery documentation for the tilde selector can be found here:

http://api.jquery.com/attribute-contains-word-selector/

like image 127
Curtis Avatar answered Oct 05 '22 00:10

Curtis


Attribute Contains Word Selector [name~="value"]

This selector matches the test string against each word in the attribute value, where a "word" is defined as a string delimited by whitespace. The selector matches if the test string is exactly equal to any of the words.

like image 20
Pranay Rana Avatar answered Oct 05 '22 00:10

Pranay Rana