使用屬性選擇:
$('a[href$=".mp3"]')...
選項:
Attribute Contains Prefix Selector [name|="value"]
Selects elements that have the specified attribute with a value
either equal to a given string or starting with that string followed
by a hyphen (-).
Attribute Contains Selector [name*="value"]
Selects elements that have the specified attribute with a
value containing the a given substring.
Attribute Contains Word Selector [name~="value"]
Selects elements that have the specified attribute with a value
containing a given word, delimited by spaces.
Attribute Ends With Selector [name$="value"]
Selects elements that have the specified attribute with a
value ending exactly with a given string. The comparison is case sensitive.
Attribute Equals Selector [name="value"]
Selects elements that have the specified attribute with a
value exactly equal to a certain value.
Attribute Not Equal Selector [name!="value"]
Select elements that either don’t have the specified attribute,
or do have the specified attribute but not with a certain value.
Attribute Starts With Selector [name^="value"]
Selects elements that have the specified attribute with a
value beginning exactly with a given string.
Has Attribute Selector [name]
Selects elements that have the specified attribute, with any value.
Multiple Attribute Selector [name="value"][name2="value2"]
Matches elements that match all of the specified attribute filters.
Check out the API瞭解更多信息。
呃,也許是第二個應該說 – Eoin 2016-09-30 13:01:54
'$('A [HREF $ =「。pdf」]')。addClass(「pdf」);' – Eoin 2016-09-30 13:02:04
編輯,謝謝。 – Aioros 2016-09-30 13:08:06