版权声明:ByRisonBoy https://blog.csdn.net/Rison_Li/article/details/82961872
1、超链接颜色设置
代码片段
<html>
<body>
<a id="1" href="https://blog.csdn.net/Rison_Li">我的博客</a>
<script type="text/javascript">
document.vlinkColor = "#ff8877"; //点击后颜色
document.linkColor = "red"; //未点击颜色
document.alinkColor = "green"; //获得焦点时颜色
</script>
</body>
</html>
结果显示:
2、前景色背景色设置
代码片段
<html>
<body>
体会前景色背景色变化
<script type="text/javascript">
var colors = new Array("#FFE4E1","#FF69B4","#E6E6FA","#CDC9C9","#98FB98","#1C86EE");
var x = 0;
function turncolors(){
x++;
if(x == (colors.length - 1)) x = 0;
document.bgColor = colors[x]; //设置页面背景色
document.fgColor = colors[x-1]; //设置文字颜色
setTimeout("turncolors()",2000);
}
turncolors();
</script>
</body>
</html>
结果显示:
3、获取文本框修改内容
代码片段
<html>
<body>
<input type="text" id="name" value="你的名字是?"/>
<input type="button" value="揭晓" name="btn" onClick="myName();"/>
<script language="javascript">
function myName(){
var name = document.getElementById("name");
name.value = "你猜吧"
}
</script>
</body>
</html>
结果显示:
其实还有很多关于文档方面的操作,这里就不一一列出了,知道有这么一个操作,很少用到。