需要实现的效果:一个输入框,当输入框未获得焦点的时候,value 值为 “密码”:当输入框失去焦点的时候,输入内容显示为”*****” <input name=”password” type=”text” id=”showPwd” tabindex=”2″ class=”input” value=”密码” /> 我们很直接会想到下面的js $(“#showPwd”).focus(function(){$(this).attr(‘type','password');}); 发现并没有实现预期效果…