Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery selector wildcard within a string [duplicate]

Links

http://domain.com/[random]/#foo

http://domain.com/[random]/bar

How to select the links that start with http://domain.com/ and then wildcard ([random]) and then #?

like image 618
Joseph Avatar asked Jul 13 '13 21:07

Joseph


1 Answers

You could do something like this:

$('a[href^="http://domain.com/"][href$="#foo"]');

That selects a elements having an href that starts with http://domain.com/ and ends with #foo.

If you don't care about the foo part and only care about the hash, use this instead:

$('a[href^="http://domain.com/"][href*="#"]');

The second part of the select is the "contains" filter.

like image 82
Jason P Avatar answered Nov 07 '22 12:11

Jason P