tags:

views:

39

answers:

3

I want to be able to search for a substring inside the href's in the below code and select the link AFTER the selected string. So, for example the string "page=2" would access the third link.

Thanks in advance.

<div id="container">
<a href='test.php?page=1&title=a title'><a title</a>
<a href='test.php?page=2&title=another title'><another title</a>
<a href='test.php?page=3&title=a last title'><a last title</a>
</div>
+1  A: 

jQuery("a[href*='page=2']").next("a"); try this

sushil bharwani
I tried it like this to check if it selected correctly -alert(jQuery("a[href*=page2]").next("a").href("href")); But nothing happens.
usertest
alert(jQuery("a[href*='page=2']").next("a").attr("href")); use attr instead of href
sushil bharwani
A: 
$('a[href*="?page=2"] + a');
BoltClock
A: 

You can do like:

$("a[href*='page2']").next("a");

Or simply:

$("a[href*='page2']").next();
Sarfraz