求助:如何改变<input type="text">为<input type="password"> document.getElementById("TextBox1").type="password";出错,无法得到type属性。应该如何实现呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Retrieves or initially sets the type of input control represented by the object注意是:initially sets the typeIE的话可以用改变outerHTML属性最好还是删了重建 type属性应该在createElement后紧接着就赋值,MSDN说的。添加到DOM树前设好type,一旦append后type就是只读的了。我个人认为在appendChild之前赋值即可。 先删除<input type="text">,在添加<input type="password"> <div id="div1"><input type="text" id="text1" name="text1"></div><input id="Button1" name="Button1" type="button" value="button" onclick="Button1_onclick()" />function Button1_onclick(){document.getElementById("div1").innerHTML='<input type="password" id="paa1" name="paa1"> '} 偶写的一个删除对象:function getObj(obj){return document.getElementById(obj)}function deleteElement(id){ //删除对象,ID为对象ID pObj=getObj(id).parentNode;//得到父对象 pObj.removeChild(getObj(id));//删除}删除之后,再新建一个<input type="password">就行了,注意它们的名字保持一样! 我的情况是这样的:设密码为123要从数据库中取回密码显示在input中,如果是<input type="password">密码框的话,界面显示为空。没有内容。<input type="text">文本框会显示123。但要的是***效果。<input type="password">密码框只有在输入的时候才会显示*** 有一种变相的方法用hidden保存值,显示到text里***用显示,用的时候用hidden里的值 TO:mingxuan3000(铭轩)在ASP。NET 中.aspx<asp:TextBox ID="txtPassword" runat="server" CssClass="TextBox" TextMode="Password"></asp:TextBox>.cstxtPassword.text="***";显示为空。password密码框在输入时才会显示‘***’。 为什么客户端事件在IE9和兼容模式下会有不一样的表现? 关于新浪微博关注js 面向对象的纯js分页组件 正则提取超级链接 javascript读取txt文件一行一行的读到末尾 追加提问 javascript 如何实现多行 链接 颜色变换 利用Java控制图片控制图片的切换方式的方法 form表单元素更改name无效 怎样接获OnClick事件 如何验证用户添入ID的有效性?就是说只能用字母、数字和下划线而不能包含别的字符 无法提取radionbutton的值 表格隐藏-显示交递问题
注意是:initially sets the typeIE的话可以用改变outerHTML属性
最好还是删了重建
添加到DOM树前设好type,一旦append后type就是只读的了。我个人认为在appendChild之前赋值即可。
</div>
<input id="Button1" name="Button1" type="button" value="button" onclick="Button1_onclick()" />
function Button1_onclick(){
document.getElementById("div1").innerHTML='<input type="password" id="paa1" name="paa1"> '
}
pObj=getObj(id).parentNode;//得到父对象
pObj.removeChild(getObj(id));//删除
}删除之后,再新建一个<input type="password">就行了,注意它们的名字保持一样!
要从数据库中取回密码显示在input中,如果是<input type="password">密码框的话,
界面显示为空。没有内容。
<input type="text">文本框会显示123。但要的是***效果。
<input type="password">密码框只有在输入的时候才会显示***
用hidden保存值,显示到text里***用显示,用的时候用hidden里的值
.aspx
<asp:TextBox ID="txtPassword" runat="server" CssClass="TextBox" TextMode="Password">
</asp:TextBox>
.cs
txtPassword.text="***";显示为空。password密码框在输入时才会显示‘***’。