JavaScript HTML DOM: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(Die Seite wurde neu angelegt: „Kategorie:Sprache = Links = * JavaScript = DOM-Elemente finden = <pre>var list = document.getElementsByTagName("UL")[0]; var elem = document.getElemen…“) |
|||
Zeile 11: | Zeile 11: | ||
= Einbindung in HTML = | = Einbindung in HTML = | ||
<pre> <button onclick="myFunction()">Click me</button> | <pre> <button onclick="myFunction()">Click me</button> | ||
<button onclick="alert('Hi')">Click to alert</button> | |||
</pre> | </pre> | ||
<pre><p onclick="myFunction()">Click me to change my text color.</p> | <pre><p onclick="myFunction()">Click me to change my text color.</p> |
Aktuelle Version vom 3. Oktober 2018, 09:15 Uhr
Links[Bearbeiten]
DOM-Elemente finden[Bearbeiten]
var list = document.getElementsByTagName("UL")[0]; var elem = document.getElementById("xyz");
Einbindung in HTML[Bearbeiten]
<button onclick="myFunction()">Click me</button> <button onclick="alert('Hi')">Click to alert</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>