Getting Started Lesson 1 of 30
Introduction to JavaScript
What JavaScript is, what it can do on a web page, and how it works together with HTML and CSS. Write and run your first line of JavaScript.
Every interactive thing you see on a website, such as a "Show answer" button, a countdown timer or a form that warns you when your phone number is wrong, is usually made with JavaScript. It is the only programming language that every web browser understands, on every phone and computer.
HTML, CSS and JavaScript
Think of a web page like a jeepney:
- HTML is the body and seats: the structure.
- CSS is the paint, chrome and stickers: the look.
- JavaScript is the engine: it makes the jeepney move and respond to the driver.
A page can exist without JavaScript, but it just sits there. With JavaScript, the page can react to what the user does.
Your first JavaScript
JavaScript code goes inside a <script> element. Press Try it yourself, then click the button in the result.
<button onclick="greet()">Click me</button>
<p id="msg"></p>
<script>
function greet() {
document.getElementById("msg").textContent = "Mabuhay! Welcome to JavaScript. 👋";
}
</script>
Here's what happened, step by step:
- The
onclickattribute tells the browser: when this button is clicked, rungreet(). greetis a function, a named set of instructions.- Inside it,
document.getElementById("msg")finds the paragraph withid="msg". .textContent = "..."replaces the text inside that paragraph.
Don't worry if not every word makes sense yet. Each of these ideas gets its own lesson.
What can JavaScript do?
<h2 id="title">Grade 10 – Rizal</h2>
<p>Total of 85 + 90 + 92 is: <strong id="sum">?</strong></p>
<button onclick="document.getElementById('sum').textContent = 85 + 90 + 92">Compute</button>
<button onclick="document.getElementById('title').style.color = 'crimson'">Make title red</button>
<button onclick="document.getElementById('title').hidden = !document.getElementById('title').hidden">Hide / show title</button>
With JavaScript you can:
- Change text and HTML on the page without reloading it
- Change styles: colors, sizes, hiding and showing things
- Compute: totals, averages, change for a purchase, grades
- React to events: clicks, typing, scrolling, timers
- Remember data in the browser and talk to servers
JavaScript is not Java
The names are similar, but they are two completely different languages, like "car" and "carpet". Java is used for Android apps and big business systems; JavaScript runs in web browsers (and, with Node.js, on servers too). If you learn one, learning the other becomes easier, but they are not the same.
Where else is JavaScript used?
JavaScript started in the browser, but today it also runs servers (Node.js), mobile apps (React Native), desktop apps (VS Code and Discord are built with it) and even some games. Learning it opens many doors.
Quick Quiz
Check what you learned. Walang grade ito, practice lang. 🙂
By Sir Reyel · Last updated 2026-12-04