<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div style="width: 60px; margin: 0 auto">
        <input id='i1' type="text" value="请输入内容" onfocus="Focus()" onblur="Blur()">

    </div>
    <script>
        function Focus() {
            tag = document.getElementById('i1');
            val = tag.value;
            if (val == '请输入内容') {
                tag.value = '';

            }
        }
        function Blur() {
            tag = document.getElementById('i1');
            val = tag.value;
            if (val.length==0){
                tag.value = '请输入内容';
            }

        }



    </script>
</body>
</html>

 

posted on 2018-07-11 18:49  python我的最爱  阅读(154)  评论(0编辑  收藏  举报