document.addEventListener('DOMContentLoaded', () => { const targetEl = document.querySelector('.passwordVisibilityToggle') targetEl.addEventListener('click', () => { const parent = targetEl.parentNode const childrenArr = Array.from(parent.children); for (let item of childrenArr) { if (item.localName === 'input') { if (item.getAttribute('type') === 'password') { targetEl.textContent = 'Скрыть пароль' item.setAttribute('type', 'text'); } else { item.setAttribute('type', 'password'); targetEl.textContent = 'Показать пароль' } return false; } } }) })