开发者社区 问答 正文

jquery中修改input标签中的type属性

执行$(input).attr("type","hidden") 会抛出

uncaught exception: type property can't be changed

展开
收起
a123456678 2016-07-08 16:22:07 2478 分享 版权
1 条回答
写回答
取消 提交回答
  • 密码:<input type="text" name="pwdPrompt" value="请输入密码" /><input type="password" name="pwd" style=" display:none;"  /> 
        <script type="text/javascript"> 
            $("input[name=pwdPrompt]").focus(function () { 
                $("input[name=pwdPrompt]").hide(); 
                $("input[name=pwd]").show().focus(); 
    
    
            }); 
            $("input[name=pwd]").blur(function () { 
                
                if ($(this).val() == "") { 
                    $("input[name=pwdPrompt]").show(); 
                    $("input[name=pwd]").hide(); 
                } 
            }) 
         </script> 
    2019-07-17 19:53:37
    赞同 展开评论