show password eye icon html code example

Example 1: how to make a show password button

function myFunction() {
  var x = document.getElementById("*passwordbox-id*");
  if (x.type === "password") {
    x.type = "text";
  } else {
    x.type = "password";
  }
}

Example 2: html show password

//Javascript show all password textboxes script by me
var k = document.getElementsByTagName('input')
for(i=0;i<k.length;i++){
    if(k[i].type = "password"){
        k[i].type = "text"
    }
}

Example 3: show password fa-eye javascript

$("body").on('click', '.toggle-password', function() {
  $(this).toggleClass("fa-eye fa-eye-slash");
  var input = $("#pass_log_id");
  if (input.attr("type") === "password") {
    input.attr("type", "text");
  } else {
    input.attr("type", "password");
  }

});