acaciadigital.cl
true

Guide

JavaScript basics: behaviour

JavaScript runs in the browser and lets a page respond to what people do.

Behaviour

Events, the DOM and data

The browser turns HTML into a tree of objects called the DOM. Scripts can read that tree and change it.

Events

Clicks, key presses and form submissions are events. A script listens for them and runs a function.

Requesting data

fetch asks a server for data and returns a promise, so the page stays usable while it waits.

A good habit

Build the content and links in HTML first, then add scripts on top. The page keeps working if a script is slow or fails.

Ask a question