老师看一下

来源:4-3 编程练习

精慕门407314

2019-12-19 13:50:36

<!DOCTYPE html>

<html>


<head>

    <meta charset="UTF-8">

    <title>习题</title>

</head>


<body>

    <input type="text" value=""><span></span>

    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>

    <script>

    //此处写代码

   $(document).ready(function(){

   $("input").blur(function(){

   if($(this).val()){

   $(this).css({"borderColor":"green"})

   }else{

   $(this).css({"borderColor":"red"})

   }

   if($(this).val()){

   $("span").text("")

   }else{

   $("span").text("请输入用户名")

   }

   })

   $("input").focus(function(){

  if($(this).val()){

  $("span").text("")

  }else{

  $("span").text("请输入用户名")

  }

  $(this).css({"borderColor":"#ccc"})

   })

   })

   

    </script>

</body>


</html>


写回答

2回答

好帮手慕糖

2019-12-19

同学你好,已经在你的另一个问题中进行了回复,可以查看另一个问题,即:https://class.imooc.com/course/qadetail/179701 

如果我的回答帮助到了你,欢迎采纳,祝学习愉快~

0

精慕门407314

提问者

2019-12-19

老师重复提问了,回答一个就可以了

0

0 学习 · 14456 问题

查看课程