Select <a> which href ends with some string

Aximili picture Aximili · Nov 20, 2008 · Viewed 468.3k times · Source

Is it possible using jQuery to select all <a> links which href ends with "ABC"?

For example, if I want to find this link <a href="http://server/page.aspx?id=ABC">

Answer

tvanfosson picture tvanfosson · Nov 20, 2008
   $('a[href$="ABC"]')...

Selector documentation can be found at http://docs.jquery.com/Selectors

For attributes:

= is exactly equal
!= is not equal
^= is starts with
$= is ends with
*= is contains
~= is contains word
|= is starts with prefix (i.e., |= "prefix" matches "prefix-...")