document.getElementById("TextBox1").type="password";
出错,无法得到type属性。应该如何实现呢?

解决方案 »

  1.   

    Retrieves or initially sets the type of input control represented by the object
    注意是:initially sets the typeIE的话可以用改变outerHTML属性
    最好还是删了重建
      

  2.   

    type属性应该在createElement后紧接着就赋值,MSDN说的。
    添加到DOM树前设好type,一旦append后type就是只读的了。我个人认为在appendChild之前赋值即可。
      

  3.   

    先删除<input type="text">,在添加<input type="password">
      

  4.   

    <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"> '
    }
      

  5.   

    偶写的一个删除对象:function getObj(obj){return document.getElementById(obj)}function deleteElement(id){ //删除对象,ID为对象ID
    pObj=getObj(id).parentNode;//得到父对象
    pObj.removeChild(getObj(id));//删除
    }删除之后,再新建一个<input type="password">就行了,注意它们的名字保持一样!
      

  6.   

    我的情况是这样的:设密码为123
    要从数据库中取回密码显示在input中,如果是<input type="password">密码框的话,
    界面显示为空。没有内容。
    <input type="text">文本框会显示123。但要的是***效果。
    <input type="password">密码框只有在输入的时候才会显示***
      

  7.   

    有一种变相的方法
    用hidden保存值,显示到text里***用显示,用的时候用hidden里的值
      

  8.   

    TO:mingxuan3000(铭轩)在ASP。NET 中
    .aspx
    <asp:TextBox ID="txtPassword" runat="server" CssClass="TextBox" TextMode="Password">
    </asp:TextBox>
    .cs
    txtPassword.text="***";显示为空。password密码框在输入时才会显示‘***’。