IE与FF,chrome对type属性值的异同

来源:互联网 发布:数据库管理员能干什么 编辑:程序博客网 时间:2024/04/29 02:00
HTML代码:               <tr>                    <td height="60" valign="middle" align="right" class="f14">                        设置密码:                    </td>                    <td class="t1">                        <input id="upwd" type="password" class="reg_text w245" name="upwd" /><label class="f16 cred">*</label>                        <input type="checkbox" id="viewpwd" /><label for="viewpwd">显示密码字符</label>                    </td>                </tr>                <tr>                    <td height="60" valign="middle" align="right" class="f14">                        确认密码:                    </td>                    <td class="t1">                        <input id="upwd2" type="password" class="reg_text w245" name="upwd2" /><label class="f16 cred">*</label>                    </td>                </tr>FF,chrome下,运行没问题;  IE下运行有问题    <script type="text/javascript">        $(function () {            $("#viewpwd").click(function () {                var _f = $(this);                $(".t1 input:first-child").each(function (k, v) {                    var _p = $(v).parent();                    var _t = _f.attr("checked") ? "text" : "password";                    _p.prepend($(v).clone().attr("type", _t));                    $(v).remove();                });            });        });    </script>FF,CHROME,IE下运行都没问题    <script type="text/javascript">        $(function () {            $("#viewpwd").click(function () {                var _f = $(this);                $(".t1 input:first-child").each(function (k, v) {                    var _p = $(v).parent();                    var _id = $(v).attr("id");                    var _class = $(v).attr("class");                    var _type = $(v).attr("type");                    var _value = $(v).attr("value");                    var _t = _f.attr("checked") ? "text" : "password";                    _p.prepend("<input type=\"" + _t + "\" id=\"" + _id + "\" class=\"" + _class + "\" value=\"" + _value + "\" name=\"" + _id + "\" />");                    $(v).remove();                });            });        });   </script>


小结:ie下type是只读的;ff和chrome下,type是可读可写的。

 

参考:http://www.cnblogs.com/wlstyle/archive/2009/05/29/1491840.html



原创粉丝点击