1.document的概念:window的子对象,由于DOM对象模型的默认对象就是window,因此Window对象中的方法和子对象不需要通过Window来引用。
-
2.document的组成:属性,方法和事件。
2.1 document的属性
-
linkColor:没有被访问的链接的颜色。
alinkColor:链接被单击时候的颜色。
vlinkColor:已经经过访问的链接的颜色。
<script> document.linkColor="#fff"; document.alinkColor="red"; document.vlinkColor="blue"; </script>
-
cookie:表示cookie的值。
2.2document的方法
write和writeln:在文档中输出数据。writeln多了一个回车符,需要放在<pre></pre>标签里才能使用。
creatElement():动态的创建HTML标记
<script> var add=document.creatElement("input"); add.type="button"; add.value="按钮"; document.form1.appendChild(add); </script>