<input type="password">
<input style="display: none;">
<input type="button" value="show/hide">
<script>
window.onload = function () {
function f(el1, el2) {
el2.style.display = 'inline';
el1.style.display = 'none';
el2.value = el1.value;
}
var els = document.body.children;
els[2].onclick = function () {
if (navigator.userAgent.indexOf('MSIE') != -1) {
if (els[1].style.display != 'inline') {
f(els[0], els[1]);
} else {
f(els[1], els[0])
}
return;
}
if (els[0].getAttribute('type') != 'text') {//
els[0].setAttribute('type', 'text');
} else {
els[0].setAttribute('type', 'password');
}
}
}
</script>
либо через insertAdjacentHTML