jQuery browser language detection
You can split the navigator.language
into two and only use the first parameter (the language) and use that to select the li
that has that class:
var userLang = navigator.language || navigator.userLanguage;// Check if the li for the browsers language is available// and set active if it is availableif($('.' + userLang.split('-')[0]).length) { $('li').removeClass('active'); $('.' + userLang.split('-')[0]).addClass('active');}
Or are you also going to be changing the li
according to the country (for example US and UK english)?