Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select link based on partial href

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.

like image 955
griegs Avatar asked Jul 20 '10 00:07

griegs


1 Answers

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.

like image 74
Nick Craver Avatar answered Oct 02 '22 22:10

Nick Craver