Home Select <a> which href ends with some string
Reply: 4

Select <a> which href ends with some string

Aximili
1#
Aximili Published in 2008-11-20 00:23:58Z

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">

tvanfosson
2#
tvanfosson Reply to 2014-07-14 15:59:54Z
   $('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-...")
James Hill
3#
James Hill Reply to 2011-12-05 17:17:01Z
$('a[href$="ABC"]:first').attr('title');

This will return the title of the first link that has a URL which ends with "ABC".

Brandon
4#
Brandon Reply to 2012-02-29 15:42:50Z
$("a[href*='id=ABC']").addClass('active_jquery_menu');
Anujith
5#
Anujith Reply to 2013-02-21 07:59:49Z
$("a[href*=ABC]").addClass('selected');
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.254972 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO