4-3作业

来源:4-3 编程练习

挪威_

2020-01-23 21:49:16

<!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").focus(function () {

            $("span").html("请输入用户名").css({color: "inherit"});

            $(this).css({border:"1px solid #dfdddd"});

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

                if ($("input").val() == "") {

                    $("span").html("用户名不能为空").css({color: "red",});

                    $(this).css({border:"1px solid red"});

                }

                else {

                    $("span").html(null);

                    $(this).css({border:"1px solid green"});

                }

            })

        })

    })

   

    </script>

</body>


</html>


写回答

1回答

好帮手慕星星

2020-01-29

同学你好,代码是正确的,很棒。继续加油,祝学习愉快!

0

0 学习 · 36712 问题

查看课程

相似问题

3-3作业

回答 1

2-4作业

回答 1

5-2作业

回答 1

2-2作业

回答 1