JQuery selector pattern in string

References

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

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

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

+7
jquery jquery-selectors
source share
2 answers

You can do something like this:

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

This selects a elements having href , which 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 selection is the β€œcontains” filter.

+7
source share

Something like that?

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

See the StartWith Selector

0
source share

All Articles