<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" Content="text/html; charset=utf-8" />
<title>javascript</title>
<style type="text/css">
body{font-size:12px;}
#txt{
height:400px;
width:600px;
border:#333 solid 1px;
padding:5px;}
p{
line-height:18px;
text-indent:2em;}
</style>
</head>
<body>
<h2 id="con">JavaScript course</H2>
<div id="txt">
<h5>JavaScript index</h5>
<p>1. JavaScript elementary</p>
<p>2. JavaScript advanced</p>
<p>3. more functions</p>
</div>
<form>
<!--当点击相应按钮,执行相应操作,为按钮添加相应事件-->
<input type="button" value="change color" onclick="changecolor()">
<input type="button" value="change size" onclick="changesize()">
<input type="button" value="hide content" onclick="hidecontent()">
<input type="button" value="show content" onclick="showcontent()">
<input type="button" value="remove all style" onclick="remove()">
</form>
<script type="text/javascript">
var text=document.getElementById("txt");
//定义"改变颜色"的函数
function changecolor(){
text.style.color="red";
text.style.backgroundColor="gray";
};
//定义"改变宽高"的函数
function changesize () {
txt.style.width="200px";
txt.style.height="200px";
}
//定义"隐藏内容"的函数
function hidecontent () {
txt.style.display="none";
}
//定义"显示内容"的函数
function showcontent () {
txt.style.display="block";
}
//定义"取消设置"的函数
function remove () {
text.removeAttribute("style");
}
</script>
</body>
</html>