
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<style type="text/css">
.div_c{
color:#FF0000;
font-style:italic;
font-size:10px;
}
</style>
<script type="text/javascript">
function js_change(){//添加样式
document.getElementById('d1').className='div_c';
}
function setSize()//设置大小
{
document.getElementById( "d1" ).style.fontSize = "30px";
}
function setColor()//设置颜色
{
document.getElementById( "d1" ).style.color = "black";
}
function setbgColor()//设置背景色
{
document.getElementById( "d1" ).style.backgroundColor = "blue";
}
function setBd()//设置边框
{
document.getElementById( "d1" ).style.border = "3px solid #FA8072";
}
function setImg(){//设置图片
document.body.style.backgroundImage = "url(http://www.google.cn/intl/zh-CN/images/logo_cn.gif)";
}
function setWidth(){//设置宽度
document.getElementById( "d1" ).style.width = "40%";
}
function setCenter(){//居中显示
document.getElementById( "d1" ).style.textAlign = "center";
}
</script>
</head>
<body>
<div class="" id="d1">
变!变!变!
</div>
<button οnclick="js_change()">变</button>
<button οnclick="setSize()">变大</button>
<button οnclick="setbgColor()">变景</button>
<button οnclick="setColor()">变色</button>
<button οnclick="setBd()">变框</button>
<button οnclick="setImg()" >变图</button>
<button οnclick="setWidth()" >变窄</button>
<button οnclick="setCenter()" >变后</button>
</body>
</html>