jQuery [name="value"][name2="value2″] Selector
Example
Find the input fields that match the conditions using a compound selector, and set their values.
<
input
id
=
"
man-news
"
name
=
"
man-news
"
/> <
input
name
=
"
milkman
"
/> <
input
id
=
"
letterman
"
name
=
"
new-letterman
"
/> <
input
name
=
"
newmilk
"
/> <
script
$
(
function
(
)
{
$
(
"
input[id][name$='man']
"
)
.
val
(
"
Only this input field
"
)
;
}
)
script
Try it »
Definition and Usage
[name="value"][name2="value2"] is a compound attribute selector, used when multiple conditions must be met at the same time.
Syntax
$
( "[attributeFilter1][attributeFilter2][attributeFilterN]" )
| Parameters | Description |
|---|---|
| attributeFilter1 | Selector type: An attribute selector |
| attributeFilter2 | Selector type: Another attribute selector, used to further narrow the scope |
| attributeFilterN | Selector type: Any number of attribute selectors |
jQuery selector