81,095
社区成员
发帖
与我相关
我的任务
分享
<input name="ui.upassWord" id="gpass" type="password" value="123456" size="25" />
<input type=button value=set onclick="setAttr();">
<input type=button value=view onclick="view();">
<script type="text/javascript">
function view(){
alert(document.getElementById("gpass").getAttribute("type"));
}
function setAttr(){
var obj=document.getElementById("gpass");
var t=document.createElement("input");
t.setAttribute("name",obj.getAttribute("name"));
t.setAttribute("id",obj.getAttribute("id"));
t.setAttribute("value",obj.getAttribute("value"));
t.setAttribute("size",obj.getAttribute("size"));
t.setAttribute("type","text");
obj.parentNode.insertBefore(t,obj);
obj.parentNode.removeChild(obj);
}
</script>