I have a simple html with a input box(id=input) and a button(id=button) with 'Show' as button's text. I have wrote JavaScript to change show to hide on click and basic stuff.
Initinally , no button is displayed (as button display is none). What I want is as soon as I type anything in the input box Show button should display. How to do so in JavaScript?
Here is my JavaScript:-
let input = document.getElementById('input');
let btn = document.getElementById('button');
btn.addEventListener('click', () => {
if (btn.innerText === "SHOW") {
btn.innerText = "HIDE";
input.type = "text";
} else {
btn.innerText = "SHOW";
input.type = "password";
}
})