標籤:使用 strong html div htm new jquery ef
屬性過濾(Attribute Filters)的內容就是html元素中的屬性
其包括以下幾個選取器:
[attribute]
[attribute=value]
[attribute!=value]
[attribute^=value]
[attribute$=value]
[attribute*=value]
[attributeFilter1][attributeFilter2][attributeFilterN]
[attribute]
用法: $(“div[id]“) ;
說明: 匹配包含給定屬性的元素.例子中是選取了所有帶”id”屬性的div標籤.
[attribute=value]
用法: $(“input[name=‘newsletter‘]“).attr(“checked”, true);
說明: 匹配給定的屬性是某個特定值的元素.例子中選取了所有 name 屬性是 newsletter 的 input 元素.
[attribute!=value]
用法: $(“input[name!=‘newsletter‘]“).attr(“checked”, true);
說明: 匹配所有不含有指定的屬性,或者屬性不等於特定值的元素.此選取器等價於:not([attr=value]),要匹配含有特定屬性但不等於特定值的元素,請使用[attr]:not([attr=value]).嗯,之前看到的 :not 派上了用場.
[attribute^=value]
用法: $(“input[name^=‘news‘]“) ;
說明: 匹配給定的屬性是以某些值開始的元素.
[attribute$=value]
用法: $(“input[name$=‘letter‘]“) ;
說明: 匹配給定的屬性是以某些值結尾的元素.
[attribute*=value]
用法: $(“input[name*=‘man‘]“) ;
說明: 匹配給定的屬性是以包含某些值的元素.
[attributeFilter1][attributeFilter2][attributeFilterN]
用法: $(“input[id][name$=‘man‘]“) ;
說明: 複合屬性選取器,需要同時滿足多個條件時使用.是一個組合.這個例子中選擇的是所有含有 id 屬性,並且它的 name 屬性是以 man 結尾的元素.