效果:將字串替換

學習重點:

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>

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 hfnkiki 的頭像
    hfnkiki

    我要勇敢地追逐我的世界.我的夢...

    hfnkiki 發表在 痞客邦 留言(0) 人氣()