js添加控件
<html>
<head>
<script type="text/javascript">
function addTest() {
document.getElementById('div1').innerHtml="<span>Test Span</span>";
}
</script>
</head>
<body>
<div id="div1">
</div>
<div id="div2">
<input type="button" value="添加" onclick="addTest()"/>
</div>
</body>
</html>
======================================================
请问一下,为什么执行addTest()方法后,span显示不出来呢?
------解决方案--------------------
是 innerHTML
HTML code
<html>
<head>
<script type="text/javascript">
function addTest() {
document.getElementById('div1').innerHTML="<span>Test Span</span>";
}
</script>
</head>
<body>
<div id="div1">
</div>
<div id="div2">
<input type="button" value="添加" onclick="addTest()"/>
</div>
</body>
</html>
------解决方案--------------------
.innerHTML 大小写敏感的