Skip to content

Instantly share code, notes, and snippets.

@loadedsith
Created April 23, 2015 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loadedsith/503575ad041f873bdcb5 to your computer and use it in GitHub Desktop.
Save loadedsith/503575ad041f873bdcb5 to your computer and use it in GitHub Desktop.
Toggle html[lang=___] script
var DEFAULT_VALUE = 'ru-ru';
function toggle (language) {
language = (typeof language === 'undefined') ? DEFAULT_VALUE : language;
var currentLang = $('html').attr('lang');
if (currentLang === 'en') {
$('html').attr('lang', language);
}else if (currentLang === language) {
$('html').attr('lang', 'en');
} else {
//If its not en or default, lets toggle back to en, so the loop is loopie
$('html').attr('lang', 'en');
}
console.log('currentLang: ', $('html').attr('lang'));
}
toggle();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment