Javascript – Use wildcards to trace an a.href in the querySelectorAll NodeList
Let's say that instead of looking at the ID, I want to select all a.href elements that contain (a piece of) this example: if document.url is "www.youtube.com". var youtubeID = document.querySelectorAll('.youtubelink'); var youtubeDiv = document.querySelectorAll('a[href^="http://www.youtube.com"]');