view raw
JaSon JaSon - 7 months ago 32
jQuery Question

Check all matches with combined string + array

I'm trying to hide some unique links from a site's product listing page.
Those links' href attributes endings are set in my "hrefs" array.
I'd like to include only the endings (instead of the whole url-s), since the part before them are always the same.

The links which I want to hide from the site (in this case) are:

My script is the next, the problem is it is only hiding the first match ( ).

var hrefs = [ "4123", "4124", "4130", ];
var fullhref = ("") + (hrefs);
return fullhref.indexOf(this.href) >-1;

So it can combine the first part of the url and the last part from the array and remove that link, but only the first one.
I need some help how could the code check all of the given url endings (and hide all)?


you can modify the array with a loop then use it to filter the selection.

var hrefs = [ "4123", "4124", "4130", ];

for(var i = 0; i< hrefs.length; i++){
hrefs[i] = "" + hrefs[i];