HTML+CSS(복습)

2023-05-16(화) focus , blur(로그인창)

박성하하 2023. 5. 17. 12:30
728x90
반응형

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../js/jquery.min.js"></script>
    <style>

    </style>
    <script>
        $(document).ready(function(){
            $("#user_id_1,#user_pw_1").on("focus",function(){
                $(this).css({"background-color":"grey"})
            })
            $("#user_id_1,#user_pw_1").on("blur",function(){
                $(this).css({"background-color":"#fff"})
            })
        })  
       
    </script>
   
    <title>Document</title>
</head>
<body>
    <h1>focus / blur</h1>
    <form action="#">
        <p>
            <label for="user_id_1">ID</label>
            <input type="text" id="user_id_1"/>
        </p>
        <p>
            <labe for="user_pw_1">PW</labe>
            <input type="password" id="user_pw_1"/>
        </p>
    </form>
</body>
</html>

focus - 포커스를 받을때

blur - 포커스를 잃을때     발생

728x90
반응형