Attribute Starts With Selector [name^="value"]

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 beginning exactly with a given string.
This selector can be useful for identifying elements in pages produced by server-side frameworks that produce HTML with systematic element IDs. However it will be slower than using a class selector so leverage classes, if you can, to group like elements.
描述:选择指定属性的属性值是以给定的字符串开头的所有元素。
在识别由服务器端框架生成的有体系IDs的HTMl页面元素时,该选择是非常有用的。但该选择比class选择器慢,如果可以应尽量使用class来组织类似的元素。

Example:
Finds all inputs with an attribute name that starts with 'news' and puts text in them.
例子:查找name属性的属性值中以'news'开头的所有input元素,然后输入一些文字。
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<input name="newsletter" />

<input name="milkman" />
<input name="newsboy" />
<script>$('input[name^="news"]').val('news here!');</script>

</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值