日期:2014-05-16 浏览次数:20332 次
function $(id){
return document.getElementById(id);
}
.....
<body>
<div id="node" >新浪</div>
<input name="btnChange" id="btnChangeId" type="button" value="改变层内容" onclick="javascript:$('node').innerHTML='<p>yahoo</p>';" /><br />
.........
</body>
<body>
<div id="node" >新浪</div>
<input name="btnChange" id="btnChangeId" type="button" value="改变层内容" onclick="javascript:document.getElementById('id').innerHTML='<p>yahoo</p>';" /><br />
.....
</body>
就会正常的显示。调试半天没发现错误。求高人指教!
<script type="text/javascript">
function $(id){
return document.getElementById(id);
}
</script><body>
<div id="node" >新浪</div>
<input name="btnChange" id="btnChangeId" type="button" value="改变层内容" onclick="javascript:$('node').innerHTML='<p>yahoo</p>';" /><br />
</body>