总有人间一两风,填我十万八千梦

jQuery .Attribute Contains Prefix Selector [name ="value"] 用法 手册 | 示例代码

jQuery开发手册 归档 226℃ 0评论

描述: 选择指定属性值等于给定字符串或以该字符串为前缀(该字符串后跟一个连字符“-” )的元素。

  • 添加的版本: 1.0jQuery( “[attribute =’value’]” )

    attribute: 一个属性名.

    value: 一个属性值,引号是可选的. 可以是一个不带引号的一个单词或带一个引号的字符串。

这个选择器是引入CSS规范来处理语言属性。

例子:

查找hreflang属性值是英语的所有链接。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!DOCTYPE html>
<html>
<head>
<style>
a { display: inline-block; }
</style>
<script src="https://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<a href="example.html" hreflang="en">Some text</a>
<a href="example.html" hreflang="en-UK">Some other text</a>
<a href="example.html" hreflang="english">will not be outlined</a>
<script>
$('a[hreflang ="en"]').css('border','3px dotted green');
</script>
</body>
</html>

转载请注明:悠然品鉴 » jQuery .Attribute Contains Prefix Selector [name ="value"] 用法 手册 | 示例代码

喜欢 (0)or分享 (0)
发表我的评论
取消评论

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址