效果:將字串替換
學習重點:
1.<p>段落
2.<id>段落指定
3.找某段落:document.getElementByID()
4.document.getElementById().innerHTML
<html>
<head>
<script>
function myFun()
{
document.getElementById("demo").innerHTML="Hello"; //用以設定或存取元素 (element) 的內容,取代This is paragraph文字
}
</script>
</head>
<body>
<p id="demo">This is a paragraph.</p> //落段設定id
<button type="button" onclick="myFun()">
Push me!
</button>
</body>
</html>
全站熱搜
留言列表