- This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
Viewing 7 posts - 1 through 7 (of 7 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Wildcard string
I’m trying to select a file path of sub-folders in javascript but have the last folder be a wild card. For example:
site.com/fruit/apple/
site.com/fruit/banana/
site.com/fruit/pear/
So something like:
("/fruit/" + * + "/")
Except I don’t know what to put in the * area to account for the above folders. The folders are dynamic so I can’t just do it by hand
Hey Noah :)
How about: $(‘a[href^=”http://site.com/fruit/”%5D’)
Hey jamy :]
That almost works. I need to make sure it’s matched to a sub folder and isn’t just targeting “http://www.site.com/fruit/” but whatever dynamically generated file path inside it is.
You could do something like:
$(‘a[href*=”/fruit/”]’)
Using $(‘a[href*=”/fruit/”]’) would include “http://www.site.com/fruit/” and I dont want that. I only want to select ones that have another sub folder like “http://www.site.com/fruit/xxxxxxxxx/“
$(‘a[href*=”/fruit/”]’).not(‘a[href$=”/fruit/”]’);
Select the anchors if they have ‘/fruit/’ but not if it ends in ‘/fruit/’
ah, I see, that totally works. Thanks a lot jamy