<script> window.onload=function(){ var div1=document.getElementById("div1"); var span1=document.getElementById("span1"); var text1=document.getElementById("text1"); var btn1=document.getElementById("btn1"); btn1.onclick=function(){//匿名函数 div1.innerHTML+=span1.innerHTML+text1.value+"<br/>"; //不想换行去掉<br/> 不想内容追加去掉+号 text1.value="";//清除输入框内容 } } </script> </head> <body> <div id="div1"></div> <span id="span1">苍老师:</span> <input id="text1" type="text"/> <input id="btn1" type="button" value="提交"/> </body> </html>