jQuery [attribute | = value]セレクター

❮jQueryセレクター

値「Tomorrow」で始まるtitle属性を持つすべての<p>要素を選択します。

$("p[title|='Tomorrow']")

定義と使用法

[attribute | = value]セレクターは、指定された属性を持つ各要素を選択します。値は、指定された文字列( "en"など)に等しいか、その文字列で始まり、その後にハイフン( "en-us"など)が続きます。

ヒント:このセレクターは、言語属性を処理するためによく使用されます。


構文

$("[attribute|='value']")

Parameter Description
attribute Required. Specifies the attribute to find
value Required. Specifies the string the attribute value should start with

その他の例


この例では、値「en」で始まるhreflang属性を持つすべての<a>要素を選択します。


❮jQueryセレクター