JavaScript (JS) is the programming language of the web. HTML builds the page, CSS styles it and JavaScript makes it do things.
What can JavaScript do?
- Change text, images and styles on the page
- React to clicks, typing and scrolling
- Check form data before it is sent
- Load data from a server without reloading the page
- Build games, apps and even servers (with Node.js)
How does it run?
Every browser has a JavaScript engine. When the page loads, the browser reads your script and runs it line by line.
JavaScript is not Java
The names are similar, but they are completely different languages.
Example
Example — Change text with a click
HTML
<h2 id="msg">Hello!</h2>
<button onclick="document.getElementById('msg').textContent = 'You clicked the button!'">Click me</button>
JavaScript finds the heading by its id and changes its text.
Try it Now »