views:

35

answers:

3

Is there a selector in jQuery that will allow me to select all anchor tags that have a href beginning with href="/products/index?page="?

My full href is href="/products/index?page=2", but they all have the beginning in common.

+4  A: 

You can use the starts-with attribute selector, like this:

$("a[href^='/products/index?page=']")

In case you're curious, there are other attribute selectors available as well.

Nick Craver
+1. One of these days, I will be on SO, and you will be fast asleep :p
karim79
@karim79 - People sleep??
Nick Craver
@Nick - so they tell me.
karim79
@karim79 - When Nick rests, he closes his eyes and use Jaws to surf SO and answer people's questions.
Gert G
@Gert G - LOL! I can believe that ;)
karim79
+2  A: 

Attribute starts with selector

$("a[href^='/products/index?page=']")
Adam
+1  A: 

You want to use the jquery starts with psuedo selector:

$('[href^=/products/index?page=]')
BC