jQuery修改input输入框type属性时报错的处理

来源:互联网 发布:ipad淘宝卖家中心在哪 编辑:程序博客网 时间:2024/05/21 09:21

uncaught exception type property can’t be changed

使用代码$("#pwd").attr("type","password")时出现上面的错误。
猜测是该版本jQuery不允许修改控件type属性,使用原生js语句可以解决这个问题。
$("#txtpwd").focus(function () {    if ($(this).attr("type") == "text") $(this)[0].type = "password";});

补充:
发现IE不支持更改控件的type属性,无奈采用新增控件替换的方式。
1 0
原创粉丝点击