const changeLangUrl = () => {
if(lang === 'kz'){
lang= 'ru'
langText.innerHTML= 'Қазақ тілінде'
location.href = window.location.pathname + '#' + lang
langImg.src = 'images/vector/kzLang.svg'
transliteTitle(lang)
textBlockBlue.classList.remove('text_block_blue_kz')
krystal.classList.remove ('text_block_krystal_kz')
krystal.classList.remove ('.second_double_image_bottom_kz')
textBlockPhone.classList.remove('text_block_phone_kz')
}else{
lang='kz'
langText.innerHTML= 'На русском'
location.href = window.location.pathname + '#' + lang
langImg.src = 'images/vector/russianLang.svg'
transliteTitle(lang)
textBlockBlue.classList.add('text_block_blue_kz')
krystal.classList.add ('text_block_krystal_kz')
krystalImg.classList.add ('second_double_image_bottom_kz')
textBlockPhone.classList.add('text_block_phone_kz')
}
}
export const transliteTitle = (hash) =>{
const translationsTitle = langArr['large_block_title'][hash];
const count = Math.min(titels.length, translationsTitle.length);
for(let x = 0; x < count; ++x) {
titels[x].innerHTML = translationsTitle[x];
}
const tarnslationSubtitle = langArr ['large_block_subtitle'] [hash];
const countSubTitle = Math.min(titels.length, tarnslationSubtitle.length);
for(let x = 0; x < countSubTitle; ++x) {
subTitles[x].innerHTML = tarnslationSubtitle[x];
}
const translateButtons = langArr ['large_block_button'] [hash];
const buttonCount = Math.min (buttonsTl.length, translateButtons.length);
for (let x = 0; x < buttonCount; ++x){
buttonsTl[x].innerHTML = translateButtons[x]
}
applicationTitle.innerHTML = langArr ['application_title'] [hash]
inputPlaceholder.placeholder = langArr ['application_input'] [hash]
document.documentElement.setAttribute('lang', `${hash}`)
document.querySelector('title').innerHTML = langArr ['title'] [hash]
description.content = langArr ['description'] [hash]
keyWords.content = langArr ['keywords'] [hash]
}
<button class="language_block">
<img class="kz_lang" src="images/vector/kzLang.svg" alt="kz">
<p class="language_text">Қазақ тілінде</p>
</button>
Не получается запустить функцию changeLangUrl по клику на мобильном устройстве. Если запускать ее без использования eventlistener- она работает. Пробовал ловить клик на блок- та же песня. Поэтому как я понял, проблема не в кнопке...