(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]")属性选择器,接受一个使用有规则的表达式的通配符语法用来明确一个字符串开始(^)和结束($)的值。 他们也可以使用星号(*)去表明在某一个位置有某个值,或者使用叹号(!)去表明一个相反的值。
posted @ 2013-09-25 20:18  pangbangb  阅读(224)  评论(0编辑  收藏  举报