DOM-Elemente finden
var list = document.getElementsByTagName("UL")[0];
var elem = document.getElementById("xyz");
Einbindung in HTML
<button onclick="myFunction()">Click me</button>
<p onclick="myFunction()">Click me to change my text color.</p>
<script>
function myFunction() {
document.getElementById("demo").style.color = "red";
}
<button onclick="myFunction()">Copy Text</button>
<script>
function myFunction() {
document.getElementById("field2").value = document.getElementById("field1").value;
}
</script>
Typen
Dictionary
var x = { "zahl" : 33, "pair" : { "x" : true } };