开发者社区> 问答> 正文

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

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

uncaught exception: type property can't be changed

展开
收起
a123456678 2016-07-08 16:22:07 2316 0
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
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关课程

更多

相关电子书

更多
Javascript中的对象 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载