<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style type="text/css">
#div1 {width: 200px;height: 200px;border: 1px solid black;}
</style>
</head>
<body>
<input id="txt1" type="text">
<input id="put1" type="button" value="改文字" />
<br/><br/>
<div id="div1"></div>
<script>
var otxt=document.getElementById('txt1');
var oput=document.getElementById('put1');
var odiv=document.getElementById('div1');
oput.onclick=function()
{
odiv.innerHTML=otxt.value;/*innerHTML里面就是正常的HTML,可以放上p、h1等*/
}
</script>
</body>
</html>
更多专业前端知识,请上 【猿2048】www.mk2048.com