Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/************************************************************
<div id="myDropdown" class="dropdown-content">
<a href="/ja/index.html" id="JapaneseLanguage">JAPANESE</a>
<a href="/en/index.html" id="EnglishLanguage">ENGLISH</a>
</div>
*************************************************************/
$( document ).ready(function() {
var ja = document.getElementById("JapaneseLanguage");
var en = document.getElementById("EnglishLanguage");
var currentPath;
var currentUrlPath = window.location.pathname;
if ( (window.location.pathname.lastIndexOf('/en/')) == 0 ) {
currentPath = currentUrlPath.split("/en/")[1];
} else if ( (window.location.pathname.lastIndexOf('/ja/')) == 0 ) {
currentPath = currentUrlPath.split("/ja/")[1];
} else {
currentPath = "index.html";
}
ja.href = '/ja/' + currentPath;
en.href = '/en/' + currentPath;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.