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>


浙公网安备 33010602011771号