I would like to change the HTML 'input' element 'type' attribute, from type="password" to type="text".
I am aware that it would be easier to find element by ID but not every page has the same id for the password input. How do I target the password inputs and change their inner value to a type of text.
I have this few lines of JavaScript code:
a=document.getElementsByTagName("input");
a.setAttribute(type,text);
To convert all elements of type password to text:
var arr = document.getElementsByTagName("input");
for (var i = 0; i < arr.length; i++) {
if (arr[i].type == 'password') arr[i].setAttribute('type','text');
}
Note: Not all browsers allow dynamic changes to the type attribute on inputs.
This transforms every input of type password into input of type text for a document.
Array.prototype.slice.call(document.querySelectorAll('input[type="password"]'))
.forEach(function (elt) {
elt.setAttribute('type', 'text');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With