<title>DOM练习</title>
<script type="text/javascript">
//动态添加
function changeDiv(){
var p = document.getElementById("d");
//p.style.backgroundColor = "red" ;
p.innerHTML = "<font color = 'red' >这是一个动态添加的动作</font>";
//p.innerText = "<font color = 'red' >这是一个动态添加的文本</font>";
p.style.width = "600px" ;
p.style.height = "400px" ;
p.style.backgroundImage = 'url(2.jpg)';
p.style.backgroundRepeat = 'no-repeat';
p.style.backgroundPosition = '200px 50px';
alert(p.id);
}
</script>
<style type="text/css">
.d{
background-color:blue;
800px;
height:600px;
}
</style>
</head>
<body>
<div id = "d"></div>
<a href = "javascript:changeDiv()" >changeDiv</div>
</body>
</html>