課程
/前端開(kāi)發(fā)
/JavaScript
/JavaScript入門篇
document.write();
2015-09-19
源自:JavaScript入門篇 2-3
正在回答
doucment.write會(huì)覆蓋文檔 使用innerHTML可以實(shí)現(xiàn)
<script>window.onload=function(){var btn=document.getElementById('click');var p=document.getElementById('x');btn.onclick=function(){?? ?x.innerHTML="你好"?? ?}}</script></head><body><input type="button" id="click" value="click" /><p id="x"></p>
舉報(bào)
JavaScript做為一名Web工程師的必備技術(shù),本教程讓您快速入門
1 回答請(qǐng)問(wèn)為什么點(diǎn)擊第二個(gè)按鈕后頁(yè)面的內(nèi)容會(huì)被change()中document.write的內(nèi)容替換
2 回答為什么P標(biāo)簽原始內(nèi)容不會(huì)被替換
1 回答用alert替代document.write時(shí)會(huì)出現(xiàn)取消按鈕
1 回答點(diǎn)擊按鈕后,為什么按鈕會(huì)消失?
1 回答顯示內(nèi)容的按鈕沒(méi)用
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2015-09-19
doucment.write會(huì)覆蓋文檔 使用innerHTML可以實(shí)現(xiàn)
<script>
window.onload=function()
{
var btn=document.getElementById('click');
var p=document.getElementById('x');
btn.onclick=function()
{
?? ?x.innerHTML="你好"
?? ?}
}
</script>
</head>
<body>
<input type="button" id="click" value="click" />
<p id="x"></p>