課程
/前端開發
/JavaScript
/JavaScript入門篇
document.write();
2015-09-19
源自:JavaScript入門篇 2-3
正在回答
doucment.write會覆蓋文檔 使用innerHTML可以實現
<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>
舉報
JavaScript做為一名Web工程師的必備技術,本教程讓您快速入門
1 回答請問為什么點擊第二個按鈕后頁面的內容會被change()中document.write的內容替換
1 回答用alert替代document.write時會出現取消按鈕
2 回答為什么P標簽原始內容不會被替換
1 回答點擊按鈕后,為什么按鈕會消失?
1 回答顯示內容的按鈕沒用
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2015-09-19
doucment.write會覆蓋文檔 使用innerHTML可以實現
<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>