我想实现一个显示隐藏密码的功能
代码如下
在IE9 FIREFOX上都正常,但是IE6 7 8无效
请问应该如何实现呢<asp:TextBox ID="tbPwd" runat="server" TextMode="Password"></asp:TextBox>
<input id="CBShowPwd" onchange="showPwd();" type="checkbox"  />显示密码</td> <script  type="text/javascript">
        function showPwd() {
            var oCB = document.getElementById("CBShowPwd");
            var oTB = document.getElementById("tbPwd");
            if (oCB.checked == true) {
                oTB.type = "text";
            }
            else {
                oTB.type = "password";
            }
        }
    </script>JavaScriptIE6兼容IE7HTML

解决方案 »

  1.   

    在这里你可以尝试使用一下jqueryfunction showPwd() {
                if($("#CBShowPwd").checked){
                    $("#tbPwd").atter("type","text");
                }
                else {
                    $("#tbPwd").atter("type","password");
                }
            }
      

  2.   

    顶楼上,应该没有问题。
    JS的兼容问题JQuery一般都会解决了的。