Reputation: 1050
What does this selector do in jquery:
$('tr[parents*=x'+1111014+'x]');
Thanks
Upvotes: 3
Views: 109
Reputation: 11718
This is the Attribute Contains Selector [name*=”value”]
. It means find all tr elements that contain an attribute parents
containing 'x1111014x'
As @PeterKA points out *=
is for selecting element attributes.
https://api.jquery.com/attribute-contains-selector/
As @JosephMarikle mentioned in the comment 'contains' means that any part of the selectors value can contain 'x1111014x'. So this selector would match all of the following: 'x1111014x'
,'FOOx1111014xBAR'
,'FOOx1111014x'
, 'x1111014xBAR'
Upvotes: 4
Reputation: 1851
The break down (for easier understanding):
'tr[parents*=x'+1111014+'x]'
tr
is a <tr>
tag.[]
square brackets indicate an attribute selector (eg class
, style
, etc)parents
is the attribute to find*=
means that the attribute value must contain the following string
x'+1111014+'x
would be equated to a string "x1111014x"
So, all in, it would look for a tr
tag that has an attribute parents
which contains the string x1111014x
Some examples of matching elements would be:
<tr parents="x1111014x">
<td>Hello World</td>
</tr>
or
<tr parents="helloworldx1111014x">
<td>Hello World</td>
</tr>
or
<tr parents="hello x1111014x world">
<td>Hello World</td>
</tr>
Upvotes: 4
Reputation: 2501
It will select any element of the following form:
<tr parents='asdfsx1111014xasdfsa' >
<tr parents='x1111014xasdfsa' >
<tr parents='asdfsx1111014x' >
<tr parents='x1111014x' >
Basically any tr
tag, with a parents
attribute. And the parents
attribute should contain the following: x1111014x
.
See documentation on jQuery select-contains.
Upvotes: 9
Reputation: 23250
Lets break it down;
tr
will select all the <tr>
elements.[parents]
will select all the elements with attribute parents
*=
is the contains selector, it will do a match on the following string.So the selector 'tr[parents*=x1111014x]'
will select all the tr
elements on the page which have an attribute that contain the string x1111014x
.
For example:
<tr parents="xxxx1111014xxxxxx">
Upvotes: 5