JavaScript Introduction - JavaScript Tutorial - W3Teach
Home / JavaScript Tutorial / JavaScript Introduction

JavaScript Introduction

What is JavaScript?

JavaScript is the world most popular programming language. JavaScript is the programming language of the Web. JavaScript is easy to learn.

Why Study JavaScript?

JavaScript is one of the 3 languages all web developers must learn:

  1. HTML to define the content of web pages
  2. CSS to specify the layout of web pages
  3. JavaScript to program the behavior of web pages

JavaScript Can Change HTML Content

One of many JavaScript HTML methods is getElementById(). The example below finds an HTML element (with id="demo"), and changes the element content to "Hello JavaScript".

JavaScript Can Change HTML Styles (CSS)

Changing the style of an HTML element is a variant of changing an HTML attribute.

<!DOCTYPE html>
<html>
<body>

<h2>What Can JavaScript Do?</h2>

<p id="demo">JavaScript can change HTML content.</p>

<button type="button"
onclick="document.getElementById('demo').innerHTML = 'Hello JavaScript!'">
Click Me!</button>

<br><br>

<p id="demo2">JavaScript can change style too!</p>
<button onclick="document.getElementById('demo2').style.color='red'">
Change Color</button>

</body>
</html>
Test Your Knowledge!

Take our JavaScript Tutorial quiz and earn a certificate.