Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Jquery, how to Grab all links with class 'c1' and has abcdef in the href

Using jquery, I want to get all links on the page with the css class 'c1' and that have 'abcdef' in the url of the href.

So far I know how to do:

$(".c1")
like image 528
Blankman Avatar asked Jan 25 '26 05:01

Blankman


2 Answers

You can use an attribute-contains selector ([attr*=val]), like this:

$("a.c1[href*=abcdef]")
like image 150
Nick Craver Avatar answered Jan 28 '26 22:01

Nick Craver


Try something like

$('a.c1[href*="abcdef"]')

For more on jQuery selectors see Selectors

like image 45
Rune Avatar answered Jan 28 '26 21:01

Rune



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!