TG Telegram Group Link
Channel: JavaScript Tutorial
Back to Bottom
1. Open a text editor such as Notepad or Sublime Text.

2. Type the following code:

<!DOCTYPE html>
<html>
<body>

<h2>My First JavaScript Program</h2>

<button onclick="myFunction()">Click me</button>

<p id="demo"></p>

<script>
function myFunction() {
  document.getElementById("demo").innerHTML = "Hello World!";
}
</script>

</body>
</html>


3. Save the file with a .html extension.

4. Open the file in a web browser.

5. Click the "Click me" button.

6. You should see the text "Hello World!" appear on the screen.

This program uses JavaScript to change the text of an HTML element when a button is clicked. It's a simple example, but it demonstrates the basic structure of a JavaScript program and how it can interact with HTML elements on a web page. From here, you can continue to learn and experiment with JavaScript to create more complex and interactive programs.
@javascript_tut
HTML Embed Code:
2025/06/30 02:21:05
Back to Top