(3)选择元素——(6)属性选择器(Attribute selectors)

Attribute selectors are a particularly helpful subset of CSS selectors. They allow us to specify an element by one of its HTML attributes, such as a link's title attribute or an image's alt attribute. 
属性选择器是一个相当有用css选择器的子集。 它允许我们通过一个元素的html属性去明确一个元素,比如一个链接的title属性或者一个图片的alt属性。
For example, to select all images that have an alt attribute, we write the following:$('img[alt]')Attribute selectors accept a wildcard syntax inspired by regular expressions for identifying the value at the beginning (^) or ending ($) of a string.  They can also take an asterisk (*) to indicate the value at an arbitrary position within a string or an exclamation mark (!) to indicate a negated value.
比如,为了选择所有有着alt属性的的图片,我们写下下面的$("img[alt]")属性选择器,接受一个使用有规则的表达式的通配符语法用来明确一个字符串开始(^)和结束($)的值。 他们也可以使用星号(*)去表明在某一个位置有某个值,或者使用叹号(!)去表明一个相反的值。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值