yutingliuyl

在我们开发过程中特别是用户注冊时会有一个效果。就是文本框获取焦点清空提示,假设用户没有输入信息失去焦点赋值上我们的提示语

<html>
<head>
<meta http-equiv="content-type"content="text/html; charset=UTF-8"/>
<script src="http://127.0.0.1/jquery.js"></script>
<script>
$(function(){
  $("#account").focus(function(){
   var account_value=$(this).val();
   if(account_value=="请输入账号"){
    $(this).val("");
   }
  });
  $("#account").blur(function(){
   var account_value=$(this).val();
   if(account_value==""){
    $(this).val("请输入账号");
   }
  });
});
</script>
</head>      
<body>

账号:<input id="account" type="text" value="请输入账号" />

</body>
</html>
 


分类:

技术点:

相关文章:

  • 2021-12-19
  • 2021-12-19
  • 2021-12-19
  • 2021-12-19
  • 2021-12-19
  • 2021-12-19
  • 2021-12-19
  • 2017-12-12
猜你喜欢
  • 2021-12-19
  • 2021-12-19
  • 2021-12-19
  • 2021-11-30
  • 2021-12-09
  • 2021-12-19
  • 2021-12-19
相关资源
相似解决方案