JavaScript HTML DOM
Version vom 27. August 2018, 08:45 Uhr von 188.110.77.49 (Diskussion) (Die Seite wurde neu angelegt: „Kategorie:Sprache = Links = * JavaScript = DOM-Elemente finden = <pre>var list = document.getElementsByTagName("UL")[0]; var elem = document.getElemen…“)
Links
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("text2").value = document.getElementById("text2").value; document.getElementById("textarea2").innerHTML = document.getElementById("textarea2").innerHTML; var field = document.getElementById("field1"); field.style.visibility = field.style.visibility == "hidden" ? "visible" : "hidden"; } </script>