<input type="text" onclick = "{this.type='password'}" />

解决方案 »

  1.   

    你试过有用吗,我这里还是不行哦 document.getElementById("password_input")[0].type="password";也不行
      

  2.   


    <script>function doit(){
       var f = document.form1;
       var obj = f.txt;
       var pas = document.createElement("<input type='password' name='txt'>");
       obj.replaceNode(pas);
    }
    </script>
    <form name="form1" action="">
    <input type="text" name="txt">
    <input type="button" value="change" onclick="doit()"> 
    </form>
      

  3.   

    document.getElementById("password_input")[0].type="password";
    ---你这样当然不行了,为什么要加[0] ?2喽的方法不可取 ,只转换类型没必要这样去替换节点的
      

  4.   

    ``````
    我想那个TXET狂本来就存在,只是当焦点落在这个框的时候,变成了密码框
      

  5.   

    <div>
    <input  id="te" type="text" onclick = "a()" />
    </div>
    <script>
    function a(){
    var nInput=document.createElement("input");
    var oInput=document.getElementById("te");
    nInput.setAttribute("type","password");
    oInput.parentNode.replaceChild(nInput,oInput);
    }
    </script>
      

  6.   

    刚我写错了,document.getElementById("password_input").type="password"; 和document.getElementsByName("password_input")[0].type="password"; 我都试不出
      

  7.   

    type 属性只读 !~~~还是参照2楼的吧 
      

  8.   

    不懂LZ為甚麼要這樣做, <input type="password" />本來就是文本框的樣子, 只是輸入的內容會用符號代替. 看LZ的意思好像就是想用它來輸入密碼的啊, 那直接放一個password就可以了啊