Password Hide and Show with Toggle Emoji Button using JavaScript

In this tutorial we will see how to make Password Field Hide and Show with Toggle Emoji Button using JavaScript. We have used monkey emoji for this purpose, CSS and JavaScript code is given.


Take a look at the HTML code given below.

<div class="input-group">
    <input type="password" id="password" class="input">
    <span class="btn" id="btn" onclick="pass(this)">

CSS Code

CSS code is given below.

    background-color: #bbb;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 0px 10px;
    border: 2px solid #000;
    background-color: #fff;
    border-radius: 10px;
    display: flex;
    padding: 15px 5px;
    outline: none;
    font-size: 30px;
    font-size: 40px;
    padding: 15px 5px;
    cursor: pointer;

JavaScript Code

Take a look at the Pure JavaScript Code given below, in this code we have used innerHTML property to change the emoji on every click. While .type property is used to change the type of input field from text to password and vice versa.

var a =0;
function pass()

document.getElementById('password').type='password'; a=0;    


Video Tutorial

Watch our video tutorial on Password Hide and Show with Toggle Emoji Button using JavaScript.

Change Text Color On Hover with JavaScript Hide and Show div using JavaScript Get Button text with JavaScript Get textarea value with JavaScript Get table row Height with JavaScript Auto Increase width of input field with JavaScript Set Textarea maxLength with JavaScript Set Textarea Value with JavaScript JavaScript Count list items JavaScript set input field value Count Button Clicks with JavaScript Scroll Page to the Top on Click with JavaScript Change id of Element with JavaScript JavaScript Change li Text Color JavaScript Change li Text JavaScript Remove id from Element Check If id Exists in JavaScript How To Delete Table Row by id in JavaScript Update Textarea value in JavaScript Change Variable Value in JavaScript Uncheck Radio Button Dynamically JavaScript Check Radio Button Dynamically JavaScript JavaScript Check if Radio Button is Checked or Not Change h1 Tag Text with JavaScript Remove First li from ul JavaScript