jQuery('[attribute*="value"]')
attribute
An attribute name.
attribute:属性名称
value
An attribute value. Can be either an unquoted single word or a quoted string.
value:属性值。引号是可选的。
Description: Selects elements that have the specified attribute with a value containing the a given substring.
This is the most generous of the jQuery attribute selectors that match against a value. It will select an element if the selector's string appears anywhere within the element's attribute value. Compare this selector with the Attribute Contains Word selector (e.g. [attr~="word"]), which is more appropriate in many cases.
描述:选择所有具有指定属性的值中包含着给定子字符串的元素。这是一个用来匹配一个指定值的最多匹配量的jQuery属性选择器。只要选择器中指定的字符串出现在某元素的属性值里,该元素将被选中。与其他“属性包含指定文字”类型选择器(例如[attr~="word"])相比,该选择器可适用于更多情形。
Example:
Finds all inputs with a name attribute that contains 'man' and sets the value with some text.
例子:查找所有name属性值中包含'man'的input元素,然后将值改为其他文字。
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<input name="man-news" />
<input name="milkman" />
<input name="letterman2" />
<input name="newmilk" />
<script>$('input[name*="man"]').val('has man in it!');</script>
</body>
</html>
attribute
An attribute name.
attribute:属性名称
value
An attribute value. Can be either an unquoted single word or a quoted string.
value:属性值。引号是可选的。
Description: Selects elements that have the specified attribute with a value containing the a given substring.
This is the most generous of the jQuery attribute selectors that match against a value. It will select an element if the selector's string appears anywhere within the element's attribute value. Compare this selector with the Attribute Contains Word selector (e.g. [attr~="word"]), which is more appropriate in many cases.
描述:选择所有具有指定属性的值中包含着给定子字符串的元素。这是一个用来匹配一个指定值的最多匹配量的jQuery属性选择器。只要选择器中指定的字符串出现在某元素的属性值里,该元素将被选中。与其他“属性包含指定文字”类型选择器(例如[attr~="word"])相比,该选择器可适用于更多情形。
Example:
Finds all inputs with a name attribute that contains 'man' and sets the value with some text.
例子:查找所有name属性值中包含'man'的input元素,然后将值改为其他文字。
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<input name="man-news" />
<input name="milkman" />
<input name="letterman2" />
<input name="newmilk" />
<script>$('input[name*="man"]').val('has man in it!');</script>
</body>
</html>