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"]');
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745185361a4615611.html
评论列表(0条)