admin管理员组文章数量:1415460
Assume I have this url:
<a href="/browse/buy/?departments=1">Phones</a>
And I want to match it via jQUery, the problem is, link is a subset of the queried test as this as I want to use the absolute path of the current page to find the fitting link (as my page may contain more additional get parameters like /browse/buy/?departments=1&order_by=title
:
Yet None of them worked:
$( 'a[href*="/browse/buy/?departments=1&order_by=title"]' );
$( 'a[href^="/browse/buy/?departments=1&order_by=title"]' );
$( 'a[href$="/browse/buy/?departments=1&order_by=title"]' );
Assume I have this url:
<a href="/browse/buy/?departments=1">Phones</a>
And I want to match it via jQUery, the problem is, link is a subset of the queried test as this as I want to use the absolute path of the current page to find the fitting link (as my page may contain more additional get parameters like /browse/buy/?departments=1&order_by=title
:
Yet None of them worked:
$( 'a[href*="/browse/buy/?departments=1&order_by=title"]' );
$( 'a[href^="/browse/buy/?departments=1&order_by=title"]' );
$( 'a[href$="/browse/buy/?departments=1&order_by=title"]' );
Share
Improve this question
asked Aug 25, 2013 at 15:03
HellnarHellnar
65k82 gold badges208 silver badges282 bronze badges
2
-
You want to find if the link has the
departments=1
and contains with/browse/buy/
? If not, can you please clearly explain the requirements that you have? – David Thomas Commented Aug 25, 2013 at 15:08 - If we are to assume the element at the top, why would you make the selector more specific so as to exclude the given element? I can't tell what your actual issue is. How does using the absolute path of the current page factor in? – user2437417 Commented Aug 25, 2013 at 15:11
1 Answer
Reset to default 7If you want to find if the link has the departments=1
and contains with /browse/buy/
, use this:
$('a[href*="/browse/buy/"][href*="departments=1"]');
本文标签: javascriptjQuery select the link contains a urlStack Overflow
版权声明:本文标题:javascript - jQuery select the link contains a url - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745185360a2646658.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论