0

I have two links :

The first one is:

<a title="Kronos">First link</a>

the second one is:

<a title="Portal">Secondlink</a>

I want to hide the second one if the first one is loaded with javascript

How can i do it ?

Lightness Races in Orbit
  • 358,771
  • 68
  • 593
  • 989
usethe23
  • 155
  • 5

1 Answers1

1

I assume that you're setting/hiding the visibility of the first link, and then changing the visibility of the second link based on that. If that's the case, and you're using JQuery, you can use code like this:

First, you need to give the links some way to be identified.

<a title="Kronos" id="link1">First link</a>
<a title="Portal" id="link2">Secondlink</a>

Next, you can use JS:

if ($('#link1').is(':visible')) {
$('#link2').hide();
}

For more info about what I used in the if statement, check out How do I check if an element is hidden in jQuery?

Anthony C
  • 71
  • 3
  • Thank you, Do you think it is it possible to it with the jquery atribute selector $("a[title|='Kronos']") ? – usethe23 Jul 06 '17 at 20:37
  • 1
    @usethe23 Yes, I think that would work. I like to use IDs and class names because they just work more often for me. – Anthony C Jul 06 '17 at 20:39