jquery更改输入框type为密码框password

很蛋疼的一个问题:

<input type="text" id="e1" value="123" />

用juqery将文本框变成密码框

    $(document).ready(function(){
    $("#e1").val("hello world!");
    $("#e1").click(function(){
    alert('11');
    <span style="white-space: pre;"> </span>$("#e1").attr("type","password");
    $("#e1").attr("value","ni mei de ");
    });
    }); 

执行的结果:弹出11,文本框没有变!

   然后百度一下,发现type的t要大写,即Type

 

    $(document).ready(function(){
    $("#e1").val("hello world!");
    $("#e1").click(function(){
    alert('11');
    if(e1.disabled)
    <span style="white-space: pre;"> </span>("#e1").attr("Type","password");
    $("#e1").attr("value","ni mei de ");
    });
    }); 

 

 

效果就有了!

 

同样的问题还有:点击打开链接

 

posted @ 2014-08-15 11:09  webnote  阅读(798)  评论(0编辑  收藏  举报