选择<a>哪个href以某个字符串结尾

是否有可能使用jQuery来选择所有以“ABC”结尾的<a>链接?

例如,如果我想找到这个链接<a href="http://server/page.aspx?id=ABC">


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

选择器文档可以在http://docs.jquery.com/Selectors找到

对于属性:

= 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-...")

$('a[href$="ABC"]:first').attr('title');

这将返回具有以“ABC”结尾的URL的第一个链接的标题。


$("a[href*='id=ABC']").addClass('active_jquery_menu');
链接地址: http://www.djcxy.com/p/12417.html

上一篇: Select <a> which href ends with some string

下一篇: redirect to another page with anchor tag in php