Javascript - Getting Started (Hello World)

> (World Wide) Web - (W3|WWW) > Javascript (Js|ECMAScript)

1 - Declaration

If the JavaScript source is declared through a script element placed before the body, it will therefore be loaded before the body. And if the Javascript code is supposed to affect the HTML in the body, it might not work as the HTML where it is supposed to work on is not yet present.

With the DOM, you handle one element at a time but with processor libraries such as D3, jQuery, you instead handle groups of related elements.

3 - Hello World

3.1 - Console

3.2 - Selector

DOM - Selection of Node Element

var myHeading = document.querySelector("h1");
myHeading.textContent = "Hello "+myHeading.textContent+"!";


3.3 - Append

DOM - Append

var div = document.createElement("h1");
div.innerHTML = "Hello, world!";

4 - Documentation / Reference

web/javascript/getting_started.txt · Last modified: 2019/02/16 17:40 by gerardnico