How do I insert Javascript code into the second input?
<input type="checkbox" onchange="document.getElementById('pass').type = this.checked ? 'text' : 'password'"> Show password
Original code:
document.getElementById('pass').type
okey, work but..
document.getElementById('pass' 'pass2').type
The second “pass2” how can I add?
Sorry for bad English
That’s not possible, just call
getElementByIdtwice, preferably with an actual event handler function.Also, note that your code won’t work on Internet Explorer 8 and earlier (I think that’s the right version number) because it fixes
typeafter the element is added to the document.