<button type="button" onclick='document.getElementById("demo").innerHTML = "Hello JavaScript!"'>Click Me!</button>
令JavaScript can change HTML content = demo
1. document.getElementById("demo")
--> <p id="demo">JavaScript can change HTML content.</p>
2. document.getElementById("demo").innerHTML
--> "JavaScript can change HTML content."
3. document.getElementById("demo").innerHTML = "Hello!"
--> "Hello!"
4. document.getElementById("demo").innerHTML = "<a href="http://tw.youtube.com>"Youtube<a/>
--> "<a href="http://tw.youtube.com>"Youtube<a/> (超連結)
file:///C:/code/wp109b/week5/jsHello.html(範例)
<button type="button" onclick="document.getElementById('demo').style.fontSize='35px'">Click Me!</button>
<script>
document.getElementById("demo").innerHTML = "My First JavaScript";
</script>
(函數類型)
function myFunction() {
document.getElementById("demo").innerHTML = "Paragraph changed.";
(函數 另一個檔案)
<script src="myScript.js"></script>