I would like to trigger an HTML element within a PHP file from a JS file with an event listener. This is my PHP file:
<?php echo password : is <div style='visibility:visible' id='password'> ".$pass."</div>  
          <button id='togglePassword'>See</button>";  ?> 
and this is my JS file. Obviously I'm using an event listener which pointing on my password and toggle! Here is my JS file:
const toggle = document.getElementById('togglePassword');
const password = document.getElementById('password');
toggle.addEventListener("click", function () {
    console.log("test")
    if(password.style.visibility==="visible"){
        password.style.visibility=  "hidden"
    }else {
        password.style.visibility = "visible"
    }   
});
 
     
     
    