<html>
<head>
<script type="text/javascript">
function test(){
var inner=document.getElementById("testDiv");//取得id为testDiv的div
alert(inner.innerHTML);//取得testDiv中的所有内容,不光有文字,还有HTML标签,注意此时如果是innerText,只能取得文字如123
inner.innerHTML="<font color='blue'>123</font>";//试试改变其中内容
}
</script>
</head>
<body>
<div id="testDiv"><font color="red">123</font></div>
<input onclick="test()" type="button" value="试试">
</body>
</html>
温馨提示:答案为网友推荐,仅供参考