DOM基础

1、DOM简介

2、获取元素

2.1getElementById

2.2getElementsByTagName

2.3H5新方法

 

2.4获取body,html元素

 3、事件基础

4、操作元素

innerText和innerHTML的区别

 

 

显示隐藏文本框内容

<body>
    <input type="text" value="手机">
    <script>
        var t = document.querySelector('input');
        t.onfocus = function () {
            if (this.value == '手机') {
                this.value = '';
            }
            this.style.color = '#333';
        }
        t.onblur = function () {
            if (this.value == '') {
                this.value = '手机';
            }
            this.style.color = "#999";
        }

    </script>
</body>

 

 

posted @ 2022-07-28 23:29  水牛打老鼠  阅读(28)  评论(0)    收藏  举报
// 侧边栏目录 // https://blog-static.cnblogs.com/files/douzujun/marvin.nav.my1502.css