Skip to content

DEMO: How JavaScript Changes Data on a Web Page #5

Open
@alexbaumgertner

Description

@alexbaumgertner

HTML structure: Introducing basic HTML and a

with text
JavaScript DOM Manipulation:
What is the DOM (Document Object Model)?
Example of reading and changing the content dynamically
Example Code:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>JS Demo</title>
</head>
<body>
  <div id="text">Hello, World!</div>
  <button onclick="changeText()">Change Text</button>

  <script>
    function changeText() {
      document.getElementById('text').textContent = 'Text changed by JavaScript!';
    }
  </script>
</body>
</html>

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions