-1

Here's the code:

<a href="http://localhost/ja/" class="current">JP</a><span class="bogo_slash"> / </span><a href="http://localhost/">EN</a>

If I select either JP/EN, i want to have an underline below there.

Thanks!

epascarello
  • 204,599
  • 20
  • 195
  • 236

1 Answers1

1

seeing from your code you just have two static pages. just add

<style>
a {
    text-decoration: none;
}
a.current {
    text-decoration: underline;
}
</style>

and class="current" to whichever page you're on

Edit : If it's a single page, you can use this javascript

<a href="http://localhost/jp" id="jp">JP</a><span class="bogo_slash"> / </span><a href="http://localhost/" id="en">EN</a>
<script>
 var url = window.location.href;
 var link = document.getElementById("jp").getAttribute("href");
 
   if (link == url) {
   document.getElementById("jp").classList.add("current");
  } else {
    document.getElementById("en").classList.add("current");  
  }
</script>
<style>
a {
    text-decoration: none;
}
a.current {
    text-decoration: underline;
}
</style>
Anil
  • 60
  • 5
  • Sorry im new to coding, where should I post this. I have only 1 page which is the header, then the href referring to JP is the link from plugin wordpress – christian Mar 04 '21 at 06:32