javascript把text替换成password就可以了

解决方案 »

  1.   

    用户:<input type=text value="ting"><BR>
    密码:<span id="pass">
    <input type=password id=pw name="pw" value="ting">
    </span>
    <INPUT TYPE="checkbox" id="showPass" 
    onclick="
    var temp=document.getElementById('pw').value;
    if(this.checked){
    document.getElementById('pass').innerHTML='<input type=text id=pw name=pw>';
    }
    else
    {
    document.getElementById('pass').innerHTML='<input type=password id=pw name=pw>';

    document.getElementById('pw').value=temp;
    "
      

  2.   

    如果你熟悉jquery的话就很简单的,改一下它的type属性就可以的
      

  3.   

    你确定你试过,TYPE属性是不可修改的
      

  4.   

    不明白是什么原因,用js把text改成password后,就无法触发我写好的失焦事件,而直接在控制台上写失焦事件又可以触发。不知道我表达清楚没有。。呜呜呜
      

  5.   


    好吧,这个逗比问题自己解决了==。由于我也是采取替换代码的方式修改type,因此之前加载的失焦事件函数也失效了,失焦事件要写在替换代码之后让其执行。