// onloadjs: https://ryfarlane.com/article/on-load-vanilla-javascript // onclick : https://gomakethings.com/listening-for-click-events-with-vanilla-javascript/ console.log('scripts loaded'); document.onreadystatechange = function(event) { if (document.readyState === "complete") { console.log('document loaded'); document.addEventListener("click",function (event) { console.log(event.target); if(event.target.matches('.icon-eye') || event.target.matches('.icon-eye-blocked')) { console.log("click sur l'oeil"); if(document.getElementById('pwd').getAttribute("type") === "password") { document.getElementById('pwd').setAttribute("type","text"); event.target.setAttribute("class","icon-eye-blocked"); } else { document.getElementById('pwd').setAttribute("type","password"); event.target.setAttribute("class","icon-eye"); } } }); } }