代码实现:
<script type="text/javascript">
function shoppw(thebox){
var ps = document.getElementById('ps');
var pass = document.getElementById('pass');
ps.removeChild(pass);
var psImput = document.createElement("INPUT");
if(pass.type == 'password'){
psImput.type = "text";
} else {
psImput.type = 'password';
}
psImput.id = 'pass';
psImput.name = "password";
psImput.maxlength="15";
ps.appendChild(psImput);
}
</script>HTML代码:
<td class="label"> * <label for="password" accesskey="">登录密码:</label></td> <td ><div id="ps"><input type="text" name="password" maxlength="15" id="pass" /></div> <input name="checkbox2" type="checkbox" value="true" checked="checked" id="show" onclick="shoppw(this)" /> <label for="show" accesskey="">显示</label></td>
可以运行时动态改变imput元素的type属性值
Copyright © 2019- 91gzw.com 版权所有 湘ICP备2023023988号-2
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务