首页 > 代码库 > javascript学习--innerHTML
javascript学习--innerHTML
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
#divQQ {
width: 500px;
height: 350px;
border: 2px dotted #000000;
padding: 10px;
/*background-color:gray;*/
}
</style>
<script type="text/javascript">
window.onload = function () {
var divqq = document.getElementById(‘divQQ‘);
var spanke = document.getElementById(‘kefu‘);
var txtinput = document.getElementById(‘txt‘);
var btn = document.getElementById(‘btnSender‘);
//表单的innerHTML为获取该表单内所有内容
btn.onclick = function () {
divqq.innerHTML = divqq.innerHTML + spanke.innerHTML + txtinput.value + "<br/>";
txtinput.value = http://www.mamicode.com/‘‘;
}
}
</script>
</head>
<body>
<div id="divQQ"> </div>
<span id="kefu">江中客服:</span>
<input type="text" id="txt" />
<input type="button" value="http://www.mamicode.com/发送" id="btnSender" />
</body>
</html>
本文出自 “Day Day Up” 博客,请务必保留此出处http://1433189426.blog.51cto.com/8055494/1565719
javascript学习--innerHTML