Only show specific links via css or javascript/jquery on a widget that renders after the page has loadedMinimum and Maximum value of Z-INDEXJavaScript that executes after page loadScroll to the top of the page using JavaScript/jQuery?In jQuery, how to attach events to dynamic html elements?How to disable a link using only CSS?Remove CSS class from element with JavaScript (no jQuery)Selecting and manipulating CSS pseudo-elements such as ::before and ::after using jQueryIs the recommendation to include CSS before JavaScript invalid?Using CSS for fade-in effect on page loadCannot display HTML string

Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)

Shell script can be run only with sh command

How to re-create Edward Weson's Pepper No. 30?

When blogging recipes, how can I support both readers who want the narrative/journey and ones who want the printer-friendly recipe?

How can the DM most effectively choose 1 out of an odd number of players to be targeted by an attack or effect?

Accidentally leaked the solution to an assignment, what to do now? (I'm the prof)

Is there a familial term for apples and pears?

Do Phineas and Ferb ever actually get busted in real time?

What defenses are there against being summoned by the Gate spell?

Example of a relative pronoun

How can bays and straits be determined in a procedurally generated map?

How to get the available space of $HOME as a variable in shell scripting?

Why don't electromagnetic waves interact with each other?

If Manufacturer spice model and Datasheet give different values which should I use?

Suffixes -unt and -ut-

What would happen to a modern skyscraper if it rains micro blackholes?

I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine

Why is an old chain unsafe?

Is it possible to do 50 km distance without any previous training?

Is the language <p,n> belongs to NP class?

Can a German sentence have two subjects?

What are these boxed doors outside store fronts in New York?

Infinite past with a beginning?

A function which translates a sentence to title-case



Only show specific links via css or javascript/jquery on a widget that renders after the page has loaded


Minimum and Maximum value of Z-INDEXJavaScript that executes after page loadScroll to the top of the page using JavaScript/jQuery?In jQuery, how to attach events to dynamic html elements?How to disable a link using only CSS?Remove CSS class from element with JavaScript (no jQuery)Selecting and manipulating CSS pseudo-elements such as ::before and ::after using jQueryIs the recommendation to include CSS before JavaScript invalid?Using CSS for fade-in effect on page loadCannot display HTML string






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2















I've been trying to figure out a solution for a problem I am having on a website but I'm not very good with jquery/javascript.



The page we have renders some javascript after the page has loaded and renders a bunch of html/css on the page, the part we are interested looks like the following:



<div class="profile-list">
<a class="profile-profile" href="https://website.com/?profile=joe_blogs_337#show_more">Add loads of html</a>
<a class="profile-profile" href="https://website.com/?profile=sam_smith_292#show_more">Add loads of html</a>
<a class="profile-profile" href="https://website.com/?profile=john_doe_31#show_more">Add loads of html</a>
<a class="profile-profile" href="https://website.com/?profile=stack_overflow_17#show_more">Add loads of html</a>
</div>


I am wanting to only show certain profiles, if there any any profiles that do not match then we don't care about them.



I have tried doing it with CSS for example, I can hide individually via:



a.profile-profile[href$='?profile=stack_overflow_17#show_more'] 
display: none !important;



I can hide all except one via:



a.profile-profile:not([href$='?profile=stack_overflow_17#show_more']) 
display: none !important;



However, If I try and hide all except two they all show hidden...



a.profile-profile:not([href$='?profile=stack_overflow_17#show_more']), a.profile-profile:not([href$='?profile=john_doe_31#show_more']) 
display: none !important;



I'm assuming I can't do this via CSS, therefore I am looking for a fast javascript solution...



Is there a way I can detect when the external js fires so it modifies the rendered HTML as fast as possible?



I'd rather not hide all of the links via:



.main_content .profile-list .profile-profile
display: none;



To then use



$("a[href$=?profile=stack_overflow_17#show_more]").show();
$("a[href$=?profile=john_doe_31#show_more]").show();


Any help with the jQuery/Javascript would be appreciated










share|improve this question




























    2















    I've been trying to figure out a solution for a problem I am having on a website but I'm not very good with jquery/javascript.



    The page we have renders some javascript after the page has loaded and renders a bunch of html/css on the page, the part we are interested looks like the following:



    <div class="profile-list">
    <a class="profile-profile" href="https://website.com/?profile=joe_blogs_337#show_more">Add loads of html</a>
    <a class="profile-profile" href="https://website.com/?profile=sam_smith_292#show_more">Add loads of html</a>
    <a class="profile-profile" href="https://website.com/?profile=john_doe_31#show_more">Add loads of html</a>
    <a class="profile-profile" href="https://website.com/?profile=stack_overflow_17#show_more">Add loads of html</a>
    </div>


    I am wanting to only show certain profiles, if there any any profiles that do not match then we don't care about them.



    I have tried doing it with CSS for example, I can hide individually via:



    a.profile-profile[href$='?profile=stack_overflow_17#show_more'] 
    display: none !important;



    I can hide all except one via:



    a.profile-profile:not([href$='?profile=stack_overflow_17#show_more']) 
    display: none !important;



    However, If I try and hide all except two they all show hidden...



    a.profile-profile:not([href$='?profile=stack_overflow_17#show_more']), a.profile-profile:not([href$='?profile=john_doe_31#show_more']) 
    display: none !important;



    I'm assuming I can't do this via CSS, therefore I am looking for a fast javascript solution...



    Is there a way I can detect when the external js fires so it modifies the rendered HTML as fast as possible?



    I'd rather not hide all of the links via:



    .main_content .profile-list .profile-profile
    display: none;



    To then use



    $("a[href$=?profile=stack_overflow_17#show_more]").show();
    $("a[href$=?profile=john_doe_31#show_more]").show();


    Any help with the jQuery/Javascript would be appreciated










    share|improve this question
























      2












      2








      2








      I've been trying to figure out a solution for a problem I am having on a website but I'm not very good with jquery/javascript.



      The page we have renders some javascript after the page has loaded and renders a bunch of html/css on the page, the part we are interested looks like the following:



      <div class="profile-list">
      <a class="profile-profile" href="https://website.com/?profile=joe_blogs_337#show_more">Add loads of html</a>
      <a class="profile-profile" href="https://website.com/?profile=sam_smith_292#show_more">Add loads of html</a>
      <a class="profile-profile" href="https://website.com/?profile=john_doe_31#show_more">Add loads of html</a>
      <a class="profile-profile" href="https://website.com/?profile=stack_overflow_17#show_more">Add loads of html</a>
      </div>


      I am wanting to only show certain profiles, if there any any profiles that do not match then we don't care about them.



      I have tried doing it with CSS for example, I can hide individually via:



      a.profile-profile[href$='?profile=stack_overflow_17#show_more'] 
      display: none !important;



      I can hide all except one via:



      a.profile-profile:not([href$='?profile=stack_overflow_17#show_more']) 
      display: none !important;



      However, If I try and hide all except two they all show hidden...



      a.profile-profile:not([href$='?profile=stack_overflow_17#show_more']), a.profile-profile:not([href$='?profile=john_doe_31#show_more']) 
      display: none !important;



      I'm assuming I can't do this via CSS, therefore I am looking for a fast javascript solution...



      Is there a way I can detect when the external js fires so it modifies the rendered HTML as fast as possible?



      I'd rather not hide all of the links via:



      .main_content .profile-list .profile-profile
      display: none;



      To then use



      $("a[href$=?profile=stack_overflow_17#show_more]").show();
      $("a[href$=?profile=john_doe_31#show_more]").show();


      Any help with the jQuery/Javascript would be appreciated










      share|improve this question














      I've been trying to figure out a solution for a problem I am having on a website but I'm not very good with jquery/javascript.



      The page we have renders some javascript after the page has loaded and renders a bunch of html/css on the page, the part we are interested looks like the following:



      <div class="profile-list">
      <a class="profile-profile" href="https://website.com/?profile=joe_blogs_337#show_more">Add loads of html</a>
      <a class="profile-profile" href="https://website.com/?profile=sam_smith_292#show_more">Add loads of html</a>
      <a class="profile-profile" href="https://website.com/?profile=john_doe_31#show_more">Add loads of html</a>
      <a class="profile-profile" href="https://website.com/?profile=stack_overflow_17#show_more">Add loads of html</a>
      </div>


      I am wanting to only show certain profiles, if there any any profiles that do not match then we don't care about them.



      I have tried doing it with CSS for example, I can hide individually via:



      a.profile-profile[href$='?profile=stack_overflow_17#show_more'] 
      display: none !important;



      I can hide all except one via:



      a.profile-profile:not([href$='?profile=stack_overflow_17#show_more']) 
      display: none !important;



      However, If I try and hide all except two they all show hidden...



      a.profile-profile:not([href$='?profile=stack_overflow_17#show_more']), a.profile-profile:not([href$='?profile=john_doe_31#show_more']) 
      display: none !important;



      I'm assuming I can't do this via CSS, therefore I am looking for a fast javascript solution...



      Is there a way I can detect when the external js fires so it modifies the rendered HTML as fast as possible?



      I'd rather not hide all of the links via:



      .main_content .profile-list .profile-profile
      display: none;



      To then use



      $("a[href$=?profile=stack_overflow_17#show_more]").show();
      $("a[href$=?profile=john_doe_31#show_more]").show();


      Any help with the jQuery/Javascript would be appreciated







      javascript jquery html css css3






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 9 at 3:39









      RyflexRyflex

      7681346116




      7681346116






















          2 Answers
          2






          active

          oldest

          votes


















          1














          While you want to filter more hrefs.. You can create an array of expected hrefs then use .filter() with .indexOf() to hide/show them



          For exact strings






          var a_Links = [
          "?profile=stack_overflow_17#show_more",
          "?profile=john_doe_31#show_more"
          // add more expected href's .....
          ];
          $('a').filter(function()
          return a_Links.indexOf($(this).attr('href')) > -1
          ).hide(); // to show use `.show()`

          <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>


          <a class="profile-profile" href="just">A Link</a>
          <a class="profile-profile" href="?profile=stack_overflow_17#show_more">Another Link</a>
          <a class="profile-profile" href="?profile=john_doe_31#show_more">Another 2 Link</a>





          The opposite And specifically the links inside .profile-list element And contains function to find any of strings in the array indexOf any of href






          var a_Links = [
          "?profile=stack_overflow_17#show_more",
          "?profile=john_doe_31#show_more"
          // add more expected href's .....
          ];
          $('.profile-list a.profile-profile').filter(function()
          return contains(a_Links , $(this).attr('href').trim().toLowerCase()) !== 1;
          ).hide(); // to show use `.show()`


          function contains(a , href)
          var founded = 0
          for (var i = 0; i < a.length; i++)
          if(founded == 1)break;
          founded = (href.indexOf(a[i]) > -1) ? 1 : 0;

          return founded;

          <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

          <div class="profile-list">
          <a class="profile-profile" href="just">A Link</a>
          <a class="profile-profile" href="link?profile=stack_overflow_17#show_more">Another Link</a>
          <a class="profile-profile" href="link?profile=john_doe_31#show_more">Another 2 Link</a>
          </div>


          <div class="another-profile-list">
          <a class="profile-profile" href="just">A Link</a>
          <a class="profile-profile" href="?profile=stack_overflow_17#show_more">Another Link</a>
          <a class="profile-profile" href="?profile=john_doe_31#show_more">Another 2 Link</a>
          </div>








          share|improve this answer

























          • 1. Your code is hiding specific links, I'm wanting to create something opposite that where it has a list of expect links that it wants to keep visible but then it hides the links that don't exist in the matched links. 2. I'm using partial links, not full links because it can be on many different URLs 3. I can't seem to modify that so it only affects child links of profile-list with the class of profile-profile.

            – Ryflex
            Mar 9 at 4:55












          • @Ryflex see Updated answer

            – Mohamed-Yousef
            Mar 9 at 5:01











          • Ahh, yeah I was doing it the wrong way around a .profile-list and was trying == not ===. As for my point 2, for some reason it doesn't allow a portion of the link... the actual links are https://website.com/?profile=stack_overflow_17#show_more but I am only interested in filtering by ?profile=stack_overflow_17#show_more I guess a cleaner way would be for me to be able to just list their profile ID's which would be: 17 for one of them, just it would need to automatically add a _ before and #show_more after to make sure it's looking for the actual ID.

            – Ryflex
            Mar 9 at 5:21











          • @Ryflex also take in consider the lowercase and the uppercase for that you can use lowercase inside the array then use $(this).attr('href').trim().toLowerCase()

            – Mohamed-Yousef
            Mar 9 at 5:30











          • @Ryflex also take in consider the lowercase and the uppercase for that you can use lowercase inside the array then use $(this).attr('href').trim().toLowerCase()

            – Mohamed-Yousef
            Mar 9 at 5:30


















          1














          Try this:



          let removeProfiles = [
          '?profile=stack_overflow_17#show_more',
          '?profile=john_doe_31#show_more',
          ];

          $('a.profile-profile').hide();

          removeProfiles.forEach(profile=>

          $('a.profile-profile[href$="'+profile+'"]').show()

          )





          share|improve this answer

























          • That appears to work the opposite to what I am trying to acheive, I want to "keep" the listed profiles, I want to hide the ones that aren't listed! Plus it throws "undefined" at the end of when its ran.

            – Ryflex
            Mar 9 at 5:29












          • make sure to change removeProfiles array's values, although when I run it in console JS always returns undefined.

            – tphobe9312
            Mar 9 at 5:36











          • See jsfiddle.net/h4e3scb2/1 it's working opposite to how it should.

            – Ryflex
            Mar 9 at 5:40











          • i have made some changes, run that JS code without jsfiddle

            – tphobe9312
            Mar 9 at 5:49











          • I don't see any changes, where did you put them...

            – Ryflex
            Mar 9 at 6:06











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073762%2fonly-show-specific-links-via-css-or-javascript-jquery-on-a-widget-that-renders-a%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          While you want to filter more hrefs.. You can create an array of expected hrefs then use .filter() with .indexOf() to hide/show them



          For exact strings






          var a_Links = [
          "?profile=stack_overflow_17#show_more",
          "?profile=john_doe_31#show_more"
          // add more expected href's .....
          ];
          $('a').filter(function()
          return a_Links.indexOf($(this).attr('href')) > -1
          ).hide(); // to show use `.show()`

          <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>


          <a class="profile-profile" href="just">A Link</a>
          <a class="profile-profile" href="?profile=stack_overflow_17#show_more">Another Link</a>
          <a class="profile-profile" href="?profile=john_doe_31#show_more">Another 2 Link</a>





          The opposite And specifically the links inside .profile-list element And contains function to find any of strings in the array indexOf any of href






          var a_Links = [
          "?profile=stack_overflow_17#show_more",
          "?profile=john_doe_31#show_more"
          // add more expected href's .....
          ];
          $('.profile-list a.profile-profile').filter(function()
          return contains(a_Links , $(this).attr('href').trim().toLowerCase()) !== 1;
          ).hide(); // to show use `.show()`


          function contains(a , href)
          var founded = 0
          for (var i = 0; i < a.length; i++)
          if(founded == 1)break;
          founded = (href.indexOf(a[i]) > -1) ? 1 : 0;

          return founded;

          <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

          <div class="profile-list">
          <a class="profile-profile" href="just">A Link</a>
          <a class="profile-profile" href="link?profile=stack_overflow_17#show_more">Another Link</a>
          <a class="profile-profile" href="link?profile=john_doe_31#show_more">Another 2 Link</a>
          </div>


          <div class="another-profile-list">
          <a class="profile-profile" href="just">A Link</a>
          <a class="profile-profile" href="?profile=stack_overflow_17#show_more">Another Link</a>
          <a class="profile-profile" href="?profile=john_doe_31#show_more">Another 2 Link</a>
          </div>








          share|improve this answer

























          • 1. Your code is hiding specific links, I'm wanting to create something opposite that where it has a list of expect links that it wants to keep visible but then it hides the links that don't exist in the matched links. 2. I'm using partial links, not full links because it can be on many different URLs 3. I can't seem to modify that so it only affects child links of profile-list with the class of profile-profile.

            – Ryflex
            Mar 9 at 4:55












          • @Ryflex see Updated answer

            – Mohamed-Yousef
            Mar 9 at 5:01











          • Ahh, yeah I was doing it the wrong way around a .profile-list and was trying == not ===. As for my point 2, for some reason it doesn't allow a portion of the link... the actual links are https://website.com/?profile=stack_overflow_17#show_more but I am only interested in filtering by ?profile=stack_overflow_17#show_more I guess a cleaner way would be for me to be able to just list their profile ID's which would be: 17 for one of them, just it would need to automatically add a _ before and #show_more after to make sure it's looking for the actual ID.

            – Ryflex
            Mar 9 at 5:21











          • @Ryflex also take in consider the lowercase and the uppercase for that you can use lowercase inside the array then use $(this).attr('href').trim().toLowerCase()

            – Mohamed-Yousef
            Mar 9 at 5:30











          • @Ryflex also take in consider the lowercase and the uppercase for that you can use lowercase inside the array then use $(this).attr('href').trim().toLowerCase()

            – Mohamed-Yousef
            Mar 9 at 5:30















          1














          While you want to filter more hrefs.. You can create an array of expected hrefs then use .filter() with .indexOf() to hide/show them



          For exact strings






          var a_Links = [
          "?profile=stack_overflow_17#show_more",
          "?profile=john_doe_31#show_more"
          // add more expected href's .....
          ];
          $('a').filter(function()
          return a_Links.indexOf($(this).attr('href')) > -1
          ).hide(); // to show use `.show()`

          <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>


          <a class="profile-profile" href="just">A Link</a>
          <a class="profile-profile" href="?profile=stack_overflow_17#show_more">Another Link</a>
          <a class="profile-profile" href="?profile=john_doe_31#show_more">Another 2 Link</a>





          The opposite And specifically the links inside .profile-list element And contains function to find any of strings in the array indexOf any of href






          var a_Links = [
          "?profile=stack_overflow_17#show_more",
          "?profile=john_doe_31#show_more"
          // add more expected href's .....
          ];
          $('.profile-list a.profile-profile').filter(function()
          return contains(a_Links , $(this).attr('href').trim().toLowerCase()) !== 1;
          ).hide(); // to show use `.show()`


          function contains(a , href)
          var founded = 0
          for (var i = 0; i < a.length; i++)
          if(founded == 1)break;
          founded = (href.indexOf(a[i]) > -1) ? 1 : 0;

          return founded;

          <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

          <div class="profile-list">
          <a class="profile-profile" href="just">A Link</a>
          <a class="profile-profile" href="link?profile=stack_overflow_17#show_more">Another Link</a>
          <a class="profile-profile" href="link?profile=john_doe_31#show_more">Another 2 Link</a>
          </div>


          <div class="another-profile-list">
          <a class="profile-profile" href="just">A Link</a>
          <a class="profile-profile" href="?profile=stack_overflow_17#show_more">Another Link</a>
          <a class="profile-profile" href="?profile=john_doe_31#show_more">Another 2 Link</a>
          </div>








          share|improve this answer

























          • 1. Your code is hiding specific links, I'm wanting to create something opposite that where it has a list of expect links that it wants to keep visible but then it hides the links that don't exist in the matched links. 2. I'm using partial links, not full links because it can be on many different URLs 3. I can't seem to modify that so it only affects child links of profile-list with the class of profile-profile.

            – Ryflex
            Mar 9 at 4:55












          • @Ryflex see Updated answer

            – Mohamed-Yousef
            Mar 9 at 5:01











          • Ahh, yeah I was doing it the wrong way around a .profile-list and was trying == not ===. As for my point 2, for some reason it doesn't allow a portion of the link... the actual links are https://website.com/?profile=stack_overflow_17#show_more but I am only interested in filtering by ?profile=stack_overflow_17#show_more I guess a cleaner way would be for me to be able to just list their profile ID's which would be: 17 for one of them, just it would need to automatically add a _ before and #show_more after to make sure it's looking for the actual ID.

            – Ryflex
            Mar 9 at 5:21











          • @Ryflex also take in consider the lowercase and the uppercase for that you can use lowercase inside the array then use $(this).attr('href').trim().toLowerCase()

            – Mohamed-Yousef
            Mar 9 at 5:30











          • @Ryflex also take in consider the lowercase and the uppercase for that you can use lowercase inside the array then use $(this).attr('href').trim().toLowerCase()

            – Mohamed-Yousef
            Mar 9 at 5:30













          1












          1








          1







          While you want to filter more hrefs.. You can create an array of expected hrefs then use .filter() with .indexOf() to hide/show them



          For exact strings






          var a_Links = [
          "?profile=stack_overflow_17#show_more",
          "?profile=john_doe_31#show_more"
          // add more expected href's .....
          ];
          $('a').filter(function()
          return a_Links.indexOf($(this).attr('href')) > -1
          ).hide(); // to show use `.show()`

          <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>


          <a class="profile-profile" href="just">A Link</a>
          <a class="profile-profile" href="?profile=stack_overflow_17#show_more">Another Link</a>
          <a class="profile-profile" href="?profile=john_doe_31#show_more">Another 2 Link</a>





          The opposite And specifically the links inside .profile-list element And contains function to find any of strings in the array indexOf any of href






          var a_Links = [
          "?profile=stack_overflow_17#show_more",
          "?profile=john_doe_31#show_more"
          // add more expected href's .....
          ];
          $('.profile-list a.profile-profile').filter(function()
          return contains(a_Links , $(this).attr('href').trim().toLowerCase()) !== 1;
          ).hide(); // to show use `.show()`


          function contains(a , href)
          var founded = 0
          for (var i = 0; i < a.length; i++)
          if(founded == 1)break;
          founded = (href.indexOf(a[i]) > -1) ? 1 : 0;

          return founded;

          <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

          <div class="profile-list">
          <a class="profile-profile" href="just">A Link</a>
          <a class="profile-profile" href="link?profile=stack_overflow_17#show_more">Another Link</a>
          <a class="profile-profile" href="link?profile=john_doe_31#show_more">Another 2 Link</a>
          </div>


          <div class="another-profile-list">
          <a class="profile-profile" href="just">A Link</a>
          <a class="profile-profile" href="?profile=stack_overflow_17#show_more">Another Link</a>
          <a class="profile-profile" href="?profile=john_doe_31#show_more">Another 2 Link</a>
          </div>








          share|improve this answer















          While you want to filter more hrefs.. You can create an array of expected hrefs then use .filter() with .indexOf() to hide/show them



          For exact strings






          var a_Links = [
          "?profile=stack_overflow_17#show_more",
          "?profile=john_doe_31#show_more"
          // add more expected href's .....
          ];
          $('a').filter(function()
          return a_Links.indexOf($(this).attr('href')) > -1
          ).hide(); // to show use `.show()`

          <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>


          <a class="profile-profile" href="just">A Link</a>
          <a class="profile-profile" href="?profile=stack_overflow_17#show_more">Another Link</a>
          <a class="profile-profile" href="?profile=john_doe_31#show_more">Another 2 Link</a>





          The opposite And specifically the links inside .profile-list element And contains function to find any of strings in the array indexOf any of href






          var a_Links = [
          "?profile=stack_overflow_17#show_more",
          "?profile=john_doe_31#show_more"
          // add more expected href's .....
          ];
          $('.profile-list a.profile-profile').filter(function()
          return contains(a_Links , $(this).attr('href').trim().toLowerCase()) !== 1;
          ).hide(); // to show use `.show()`


          function contains(a , href)
          var founded = 0
          for (var i = 0; i < a.length; i++)
          if(founded == 1)break;
          founded = (href.indexOf(a[i]) > -1) ? 1 : 0;

          return founded;

          <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

          <div class="profile-list">
          <a class="profile-profile" href="just">A Link</a>
          <a class="profile-profile" href="link?profile=stack_overflow_17#show_more">Another Link</a>
          <a class="profile-profile" href="link?profile=john_doe_31#show_more">Another 2 Link</a>
          </div>


          <div class="another-profile-list">
          <a class="profile-profile" href="just">A Link</a>
          <a class="profile-profile" href="?profile=stack_overflow_17#show_more">Another Link</a>
          <a class="profile-profile" href="?profile=john_doe_31#show_more">Another 2 Link</a>
          </div>








          var a_Links = [
          "?profile=stack_overflow_17#show_more",
          "?profile=john_doe_31#show_more"
          // add more expected href's .....
          ];
          $('a').filter(function()
          return a_Links.indexOf($(this).attr('href')) > -1
          ).hide(); // to show use `.show()`

          <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>


          <a class="profile-profile" href="just">A Link</a>
          <a class="profile-profile" href="?profile=stack_overflow_17#show_more">Another Link</a>
          <a class="profile-profile" href="?profile=john_doe_31#show_more">Another 2 Link</a>





          var a_Links = [
          "?profile=stack_overflow_17#show_more",
          "?profile=john_doe_31#show_more"
          // add more expected href's .....
          ];
          $('a').filter(function()
          return a_Links.indexOf($(this).attr('href')) > -1
          ).hide(); // to show use `.show()`

          <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>


          <a class="profile-profile" href="just">A Link</a>
          <a class="profile-profile" href="?profile=stack_overflow_17#show_more">Another Link</a>
          <a class="profile-profile" href="?profile=john_doe_31#show_more">Another 2 Link</a>





          var a_Links = [
          "?profile=stack_overflow_17#show_more",
          "?profile=john_doe_31#show_more"
          // add more expected href's .....
          ];
          $('.profile-list a.profile-profile').filter(function()
          return contains(a_Links , $(this).attr('href').trim().toLowerCase()) !== 1;
          ).hide(); // to show use `.show()`


          function contains(a , href)
          var founded = 0
          for (var i = 0; i < a.length; i++)
          if(founded == 1)break;
          founded = (href.indexOf(a[i]) > -1) ? 1 : 0;

          return founded;

          <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

          <div class="profile-list">
          <a class="profile-profile" href="just">A Link</a>
          <a class="profile-profile" href="link?profile=stack_overflow_17#show_more">Another Link</a>
          <a class="profile-profile" href="link?profile=john_doe_31#show_more">Another 2 Link</a>
          </div>


          <div class="another-profile-list">
          <a class="profile-profile" href="just">A Link</a>
          <a class="profile-profile" href="?profile=stack_overflow_17#show_more">Another Link</a>
          <a class="profile-profile" href="?profile=john_doe_31#show_more">Another 2 Link</a>
          </div>





          var a_Links = [
          "?profile=stack_overflow_17#show_more",
          "?profile=john_doe_31#show_more"
          // add more expected href's .....
          ];
          $('.profile-list a.profile-profile').filter(function()
          return contains(a_Links , $(this).attr('href').trim().toLowerCase()) !== 1;
          ).hide(); // to show use `.show()`


          function contains(a , href)
          var founded = 0
          for (var i = 0; i < a.length; i++)
          if(founded == 1)break;
          founded = (href.indexOf(a[i]) > -1) ? 1 : 0;

          return founded;

          <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

          <div class="profile-list">
          <a class="profile-profile" href="just">A Link</a>
          <a class="profile-profile" href="link?profile=stack_overflow_17#show_more">Another Link</a>
          <a class="profile-profile" href="link?profile=john_doe_31#show_more">Another 2 Link</a>
          </div>


          <div class="another-profile-list">
          <a class="profile-profile" href="just">A Link</a>
          <a class="profile-profile" href="?profile=stack_overflow_17#show_more">Another Link</a>
          <a class="profile-profile" href="?profile=john_doe_31#show_more">Another 2 Link</a>
          </div>






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 9 at 6:31

























          answered Mar 9 at 3:59









          Mohamed-YousefMohamed-Yousef

          19.9k31224




          19.9k31224












          • 1. Your code is hiding specific links, I'm wanting to create something opposite that where it has a list of expect links that it wants to keep visible but then it hides the links that don't exist in the matched links. 2. I'm using partial links, not full links because it can be on many different URLs 3. I can't seem to modify that so it only affects child links of profile-list with the class of profile-profile.

            – Ryflex
            Mar 9 at 4:55












          • @Ryflex see Updated answer

            – Mohamed-Yousef
            Mar 9 at 5:01











          • Ahh, yeah I was doing it the wrong way around a .profile-list and was trying == not ===. As for my point 2, for some reason it doesn't allow a portion of the link... the actual links are https://website.com/?profile=stack_overflow_17#show_more but I am only interested in filtering by ?profile=stack_overflow_17#show_more I guess a cleaner way would be for me to be able to just list their profile ID's which would be: 17 for one of them, just it would need to automatically add a _ before and #show_more after to make sure it's looking for the actual ID.

            – Ryflex
            Mar 9 at 5:21











          • @Ryflex also take in consider the lowercase and the uppercase for that you can use lowercase inside the array then use $(this).attr('href').trim().toLowerCase()

            – Mohamed-Yousef
            Mar 9 at 5:30











          • @Ryflex also take in consider the lowercase and the uppercase for that you can use lowercase inside the array then use $(this).attr('href').trim().toLowerCase()

            – Mohamed-Yousef
            Mar 9 at 5:30

















          • 1. Your code is hiding specific links, I'm wanting to create something opposite that where it has a list of expect links that it wants to keep visible but then it hides the links that don't exist in the matched links. 2. I'm using partial links, not full links because it can be on many different URLs 3. I can't seem to modify that so it only affects child links of profile-list with the class of profile-profile.

            – Ryflex
            Mar 9 at 4:55












          • @Ryflex see Updated answer

            – Mohamed-Yousef
            Mar 9 at 5:01











          • Ahh, yeah I was doing it the wrong way around a .profile-list and was trying == not ===. As for my point 2, for some reason it doesn't allow a portion of the link... the actual links are https://website.com/?profile=stack_overflow_17#show_more but I am only interested in filtering by ?profile=stack_overflow_17#show_more I guess a cleaner way would be for me to be able to just list their profile ID's which would be: 17 for one of them, just it would need to automatically add a _ before and #show_more after to make sure it's looking for the actual ID.

            – Ryflex
            Mar 9 at 5:21











          • @Ryflex also take in consider the lowercase and the uppercase for that you can use lowercase inside the array then use $(this).attr('href').trim().toLowerCase()

            – Mohamed-Yousef
            Mar 9 at 5:30











          • @Ryflex also take in consider the lowercase and the uppercase for that you can use lowercase inside the array then use $(this).attr('href').trim().toLowerCase()

            – Mohamed-Yousef
            Mar 9 at 5:30
















          1. Your code is hiding specific links, I'm wanting to create something opposite that where it has a list of expect links that it wants to keep visible but then it hides the links that don't exist in the matched links. 2. I'm using partial links, not full links because it can be on many different URLs 3. I can't seem to modify that so it only affects child links of profile-list with the class of profile-profile.

          – Ryflex
          Mar 9 at 4:55






          1. Your code is hiding specific links, I'm wanting to create something opposite that where it has a list of expect links that it wants to keep visible but then it hides the links that don't exist in the matched links. 2. I'm using partial links, not full links because it can be on many different URLs 3. I can't seem to modify that so it only affects child links of profile-list with the class of profile-profile.

          – Ryflex
          Mar 9 at 4:55














          @Ryflex see Updated answer

          – Mohamed-Yousef
          Mar 9 at 5:01





          @Ryflex see Updated answer

          – Mohamed-Yousef
          Mar 9 at 5:01













          Ahh, yeah I was doing it the wrong way around a .profile-list and was trying == not ===. As for my point 2, for some reason it doesn't allow a portion of the link... the actual links are https://website.com/?profile=stack_overflow_17#show_more but I am only interested in filtering by ?profile=stack_overflow_17#show_more I guess a cleaner way would be for me to be able to just list their profile ID's which would be: 17 for one of them, just it would need to automatically add a _ before and #show_more after to make sure it's looking for the actual ID.

          – Ryflex
          Mar 9 at 5:21





          Ahh, yeah I was doing it the wrong way around a .profile-list and was trying == not ===. As for my point 2, for some reason it doesn't allow a portion of the link... the actual links are https://website.com/?profile=stack_overflow_17#show_more but I am only interested in filtering by ?profile=stack_overflow_17#show_more I guess a cleaner way would be for me to be able to just list their profile ID's which would be: 17 for one of them, just it would need to automatically add a _ before and #show_more after to make sure it's looking for the actual ID.

          – Ryflex
          Mar 9 at 5:21













          @Ryflex also take in consider the lowercase and the uppercase for that you can use lowercase inside the array then use $(this).attr('href').trim().toLowerCase()

          – Mohamed-Yousef
          Mar 9 at 5:30





          @Ryflex also take in consider the lowercase and the uppercase for that you can use lowercase inside the array then use $(this).attr('href').trim().toLowerCase()

          – Mohamed-Yousef
          Mar 9 at 5:30













          @Ryflex also take in consider the lowercase and the uppercase for that you can use lowercase inside the array then use $(this).attr('href').trim().toLowerCase()

          – Mohamed-Yousef
          Mar 9 at 5:30





          @Ryflex also take in consider the lowercase and the uppercase for that you can use lowercase inside the array then use $(this).attr('href').trim().toLowerCase()

          – Mohamed-Yousef
          Mar 9 at 5:30













          1














          Try this:



          let removeProfiles = [
          '?profile=stack_overflow_17#show_more',
          '?profile=john_doe_31#show_more',
          ];

          $('a.profile-profile').hide();

          removeProfiles.forEach(profile=>

          $('a.profile-profile[href$="'+profile+'"]').show()

          )





          share|improve this answer

























          • That appears to work the opposite to what I am trying to acheive, I want to "keep" the listed profiles, I want to hide the ones that aren't listed! Plus it throws "undefined" at the end of when its ran.

            – Ryflex
            Mar 9 at 5:29












          • make sure to change removeProfiles array's values, although when I run it in console JS always returns undefined.

            – tphobe9312
            Mar 9 at 5:36











          • See jsfiddle.net/h4e3scb2/1 it's working opposite to how it should.

            – Ryflex
            Mar 9 at 5:40











          • i have made some changes, run that JS code without jsfiddle

            – tphobe9312
            Mar 9 at 5:49











          • I don't see any changes, where did you put them...

            – Ryflex
            Mar 9 at 6:06















          1














          Try this:



          let removeProfiles = [
          '?profile=stack_overflow_17#show_more',
          '?profile=john_doe_31#show_more',
          ];

          $('a.profile-profile').hide();

          removeProfiles.forEach(profile=>

          $('a.profile-profile[href$="'+profile+'"]').show()

          )





          share|improve this answer

























          • That appears to work the opposite to what I am trying to acheive, I want to "keep" the listed profiles, I want to hide the ones that aren't listed! Plus it throws "undefined" at the end of when its ran.

            – Ryflex
            Mar 9 at 5:29












          • make sure to change removeProfiles array's values, although when I run it in console JS always returns undefined.

            – tphobe9312
            Mar 9 at 5:36











          • See jsfiddle.net/h4e3scb2/1 it's working opposite to how it should.

            – Ryflex
            Mar 9 at 5:40











          • i have made some changes, run that JS code without jsfiddle

            – tphobe9312
            Mar 9 at 5:49











          • I don't see any changes, where did you put them...

            – Ryflex
            Mar 9 at 6:06













          1












          1








          1







          Try this:



          let removeProfiles = [
          '?profile=stack_overflow_17#show_more',
          '?profile=john_doe_31#show_more',
          ];

          $('a.profile-profile').hide();

          removeProfiles.forEach(profile=>

          $('a.profile-profile[href$="'+profile+'"]').show()

          )





          share|improve this answer















          Try this:



          let removeProfiles = [
          '?profile=stack_overflow_17#show_more',
          '?profile=john_doe_31#show_more',
          ];

          $('a.profile-profile').hide();

          removeProfiles.forEach(profile=>

          $('a.profile-profile[href$="'+profile+'"]').show()

          )






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 9 at 6:08

























          answered Mar 9 at 5:08









          tphobe9312tphobe9312

          2181412




          2181412












          • That appears to work the opposite to what I am trying to acheive, I want to "keep" the listed profiles, I want to hide the ones that aren't listed! Plus it throws "undefined" at the end of when its ran.

            – Ryflex
            Mar 9 at 5:29












          • make sure to change removeProfiles array's values, although when I run it in console JS always returns undefined.

            – tphobe9312
            Mar 9 at 5:36











          • See jsfiddle.net/h4e3scb2/1 it's working opposite to how it should.

            – Ryflex
            Mar 9 at 5:40











          • i have made some changes, run that JS code without jsfiddle

            – tphobe9312
            Mar 9 at 5:49











          • I don't see any changes, where did you put them...

            – Ryflex
            Mar 9 at 6:06

















          • That appears to work the opposite to what I am trying to acheive, I want to "keep" the listed profiles, I want to hide the ones that aren't listed! Plus it throws "undefined" at the end of when its ran.

            – Ryflex
            Mar 9 at 5:29












          • make sure to change removeProfiles array's values, although when I run it in console JS always returns undefined.

            – tphobe9312
            Mar 9 at 5:36











          • See jsfiddle.net/h4e3scb2/1 it's working opposite to how it should.

            – Ryflex
            Mar 9 at 5:40











          • i have made some changes, run that JS code without jsfiddle

            – tphobe9312
            Mar 9 at 5:49











          • I don't see any changes, where did you put them...

            – Ryflex
            Mar 9 at 6:06
















          That appears to work the opposite to what I am trying to acheive, I want to "keep" the listed profiles, I want to hide the ones that aren't listed! Plus it throws "undefined" at the end of when its ran.

          – Ryflex
          Mar 9 at 5:29






          That appears to work the opposite to what I am trying to acheive, I want to "keep" the listed profiles, I want to hide the ones that aren't listed! Plus it throws "undefined" at the end of when its ran.

          – Ryflex
          Mar 9 at 5:29














          make sure to change removeProfiles array's values, although when I run it in console JS always returns undefined.

          – tphobe9312
          Mar 9 at 5:36





          make sure to change removeProfiles array's values, although when I run it in console JS always returns undefined.

          – tphobe9312
          Mar 9 at 5:36













          See jsfiddle.net/h4e3scb2/1 it's working opposite to how it should.

          – Ryflex
          Mar 9 at 5:40





          See jsfiddle.net/h4e3scb2/1 it's working opposite to how it should.

          – Ryflex
          Mar 9 at 5:40













          i have made some changes, run that JS code without jsfiddle

          – tphobe9312
          Mar 9 at 5:49





          i have made some changes, run that JS code without jsfiddle

          – tphobe9312
          Mar 9 at 5:49













          I don't see any changes, where did you put them...

          – Ryflex
          Mar 9 at 6:06





          I don't see any changes, where did you put them...

          – Ryflex
          Mar 9 at 6:06

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073762%2fonly-show-specific-links-via-css-or-javascript-jquery-on-a-widget-that-renders-a%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

          2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

          Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme