下面的例子展示了你如何用JavaScript反转HTML密码框中的内容。
<!DOCTYPE HTML>
<html>
<head>
<title>Revealing an HTML password input field using JavaScript</title>
</head>
<body>
<form>
<table>
<tr>
<th><label for="username">Username:</label></th>
<td><input id="username"
type="text"
value="peterd" /></td>
</tr>
<tr>
<th><label for="password">Password:</label></th>
<td><input id="password"
type="password"
value="meow"
onmouseover="this.type = 'text';"
onmouseout="this.type = 'password';" />
<em>Roll over the text field to display password.</em></td>
</tr>
</table>
</form>
</body>
</html>