Document Object

  • When an HTML document is loaded into a web browser, it becomes a document object.
  • The HTML document node is the root node, it contains all of the other nodes(element nodes, text nodes, attributes node, and comment nodes).
  • The HTML DOM Document Object | W3Cschool

Document Object Model, DOM

  • 中文:文件物件模型
  • 動態網頁的基礎
  • 雖然常與Javascript搭配,但其為獨立語言

innerHTML Property

<html>

<body>
    <span id="cat">meow~</span><br>
    <button onclick="myfunction()">Try it</button>
    <script>
        function myfunction() {
            x = document.getElementById("cat").innerHTML; // set the property to meow~ to x
            document.getElementById("cat").innerHTML = "WONG!"; // Set the innerHTML property to WONG!

            //Case Sensitive! 別忘記E,B,I要大寫
        }

    </script>
</body>

</html>

Javascript 放在 HTML 網頁的哪裡?

能放在<head>、<body>和前兩者外

results matching ""

    No results matching ""