jquery 如何 让text文本条中的内容被选中状态
<input type="password" name="pwd" id="pwd">
比如ajax 验证密码是错的了,我想让 这个文本条得到焦点,并且之前输入的错误密码变蓝,就和 csdn登录时候密码错了,错误的密码变蓝那种效果。jquery如何实现?
------解决方案--------------------
<input type="text" value="121212" onfocus="this.select()"/>
------解决方案--------------------$("#pwd").bind("keyup",function(){
 /*写你的校验方法
  ........
 */
 $(this).focus() ;//获得焦点
 $(this).css("color","#0000ff");//字体变色
});
------解决方案--------------------JScript code
error:function(){//ajax验证错误的时候
  $('#pwd').focus() ;//获得焦点
  $('#pwd').css("color","#0000ff");//字体变色
}
------解决方案--------------------
------解决方案--------------------
参考下,不用jquery,用默认的文本框内容选中就行
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<script type="text/javascript">
   window.onload = function () {
       var pas = document.getElementById("aa");
       //if()ajax判断密码为错误时
       pas.focus();
       pas.select();
   }
</script>
<body>
<input type="password" value="121212"  id="aa"/>
</body>
</html>