jquery获取焦点和失去焦点

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src='../jquery.js'></script>
<style>
    .hide{display:none}
    .test{background:green}
</style>
</head>
<body>
        <div id='test'>ttttt</div>
        <input type='text' id='adress' value='请输入' />
    <script>
    $(function(){
        $('#adress').focus(function(){
            var text=$(this).val();
            if(text=='请输入'){
                $(this).val('');
            }
        });
        $('#adress').blur(function(){
            var text=$(this).val();
            if(text==''){
                $(this).val('请输入');
            }
        });
    });
    </script>
    
</body>
</html>

原文地址:https://www.cnblogs.com/huifeideyu/p/jquery.html