<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>表单非空校验</title>
    <script type="text/javascript" src="jquery.min.js"></script>
    <style>
    .wait{color: green}
    </style>
</head>
<body>
<input type="text" class="ipt">
    <script type="text/javascript">
        $(function(){
            $(".ipt").blur(function(){
                if($(this).val()==""){
                $(".ipt").val("请输入关键词").addClass("wait");
                }
            });
            $(".ipt").focus(function(){
            if($(".ipt").val()=="请输入关键词"){
            $(".ipt").val("").removeClass("wait");
            }
            });
        })
    </script>
</body>
</html>

 

相关文章:

  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2021-12-19
  • 2022-12-23
猜你喜欢
  • 2021-12-19
  • 2021-12-19
  • 2022-12-23
  • 2021-07-02
  • 2022-01-15
  • 2021-12-19
  • 2022-12-23
相关资源
相似解决方案