Simple JavaScript Language Switcher

https://miro.medium.com/max/1400/0*GH3zuK_2sRtvh66b

Photo by KOBU Agency on Unsplash

javascript-language-switcher

after quite a bit of searching, I decided to create a naive one

you can just fork it to use it

simple demo

HTML

1
2
3
<h1 class="en">JavaScript Language Switcher</h1>  
    <h1 class="tw">JS語言切換</h1>  
    <span class='en' onclick="switch_lang('.en', '.tw')">中文</span><span class='tw' onclick="switch_lang('.tw', '.en')">EN</span>

JS

1
2
3
4
window.onload = switch_lang('.tw', '.en');function switch_lang(hide_lan, show_lan){  
  $(hide_lan).hide();  
  $(show_lan).show();  
}

Contact me: Hung, Chien-Hsiang (chienhsiang-hung.github.io)