1.jQuery( “[attribute|=’value’]” )
等于给定字符或以该字符串为前缀的元素。
<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>
$('a[hreflang|="en"]').css('border','3px dotted green');
将对第一个,第二个a标签添加边框。
2.jQuery( “[attribute*=’value’]” )
属性值中包含给定的值。
3.jQuery( “[attribute~=’value’]” )
用空格分隔开的单词中包含给定值。
<input name="man-news" />
<input name="milk man" />
<input name="letterman2" />
<input name="newmilk" />
$('input[name~="man"]').val('选中的标签');
只对那么属性中单独的单词man的标签选中。
4.jQuery( “[attribute$=’value’]” )
以给定值结尾的属性。
5.jQuery( “[attribute=’value’]” )
等于给定值
6.jQuery( “[attribute!=’value’]” )
反选不等于给定值的元素。
等同于 :not([attr=value])
7.jQuery( “[attribute^=’value’]” )
以给定字符串开始的元素。
8.jQuery( “[attribute]” )
选中具有指定属性的元素。
<div>no id</div>
<div id="hey">with id</div>
<div id="there">has an id</div>
<div>nope</div>
$('div[id]').one('click', function(){
var idString = $(this).text() + ' = ' + $(this).attr('id');
$(this).text(idString);
});