- Writing variable names can use letters, numbers, underscores, and dollar signs
- Writing variable names must begin with a letter
- Variable names cannot contain spaces
Well, first we prepare the html file, here I named it index.html
var nama = "Nurroin's Blog"; var alamat = "Probolinggo";
And then I output the contents of the variable into the nama and alamat elements
document.getElementById("nama").innerHTML = nama; document.getElementById("alamat").innerHTML = alamat;
document.getElementById() useful for specifying element by id in accordance with the function parameter. innerHTML to implement HTML syntax.