Wybierz, który href kończy się jakimś ciągiem

Czy za pomocą jQuery można wybrać wszystkie <a> linki, które href kończy się "ABC"?

Na przykład, jeśli chcę znaleźć ten link <a href="http://server/page.aspx?id=ABC">

 625
Author: Michael Schmidt, 2008-11-20

4 answers

   $('a[href$="ABC"]')...

Dokumentacja selektora znajduje się pod adresem http://docs.jquery.com/Selectors

Dla atrybutów:

= 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-...")
 1467
Author: tvanfosson,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-07-14 15:59:54
$('a[href$="ABC"]:first').attr('title');

Zwróci to tytuł pierwszego linku, który ma adres URL, który kończy się na "ABC".

 18
Author: Ash,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-12-05 17:17:01
$("a[href*='id=ABC']").addClass('active_jquery_menu');
 13
Author: Sumit,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-02-29 15:42:50
$("a[href*=ABC]").addClass('selected');
 3
Author: Ganesh Anugu,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-02-21 07:59:49