<script type='text/javascript'>
function showDiv(){
//创建元素 参数是元素名
var new_div = document.createElement("div");
//给div设置大小 颜色 style属性获得
new_div.style.width = '10px';
new_div.style.height = '10px';
new_div.style.backgroundColor = 'blue';
//确定位置
document.body.appendChild(new_div);
//var text=document.createTextNode("a,b,c,d");
new_div.appendChild(text);
}
</script>
<input type='button' value="试试" οnclick="showDiv()">