<p id="akapit1" class="grupa1">To jest akapit nr 1.</p> <p id="akapit2" class="grupa1">To jest akapit nr 2.</p>
To jest akapit nr 1.
To jest akapit nr 2.
<script> var akapit = document.getElementsByTagName("p"); // kolekcja akapitów document.write("<pre>"); document.write("akapit = " + akapit + "\n"); document.write("akapit.length = " + akapit.length); document.write("</pre>"); </script>https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection
<script> document.write("<pre>"); document.write("akapit[0] = " + akapit[0] + "\n"); document.write("akapit[1] = " + akapit[1] + "\n"); document.write("akapit[2] = " + akapit[2]); document.write("</pre>"); </script>
<script> document.write("<pre>"); document.write("akapit.item(0) = " + akapit.item(0) + "\n"); document.write("akapit.item(1) = " + akapit.item(1) + "\n"); document.write("akapit.item(2) = " + akapit.item(2)); document.write("</pre>"); </script>
<script> document.write("<pre>"); document.write("akapit[\"akapit1\"] = " + akapit["akapit1"] + "\n"); document.write("akapit[\"akapit2\"] = " + akapit["akapit2"] + "\n"); document.write("akapit[\"akapit3\"] = " + akapit["akapit3"]); document.write("</pre>"); </script>
<script> document.write("<pre>"); document.write("akapit.namedItem(\"akapit1\") = " + akapit.namedItem("akapit1") + "\n"); document.write("akapit.namedItem(\"akapit2\") = " + akapit.namedItem("akapit2") + "\n"); document.write("akapit.namedItem(\"akapit3\") = " + akapit.namedItem("akapit3")); document.write("</pre>"); </script>
<script> document.write("<pre>"); document.write("akapit.akapit1 = " + akapit.akapit1 + "\n"); document.write("akapit.akapit2 = " + akapit.akapit2 + "\n"); document.write("akapit.akapit3 = " + akapit.akapit3); document.write("</pre>"); </script>
<script> document.write("<pre>"); document.write("akapit[0].tagName = " + akapit[0].tagName + "\n"); document.write("akapit[1].tagName = " + akapit[1].tagName) document.write("</pre>"); </script>
<script> document.write("<pre>"); document.write("akapit[0].innerHTML = " + akapit[0].innerHTML + "\n"); document.write("akapit[0].innerHTML = " + akapit[0].innerHTML); document.write("</pre>"); </script>
<script> document.write("<pre>"); document.write("akapit[0].attributes = " + akapit[0].attributes + "\n"); document.write("akapit[0].attributes.length = " + akapit[0].attributes.length + "\n\n"); document.write("akapit[0].attributes[0] = " + akapit[0].attributes[0] + "\n"); document.write("akapit[0].attributes[1] = " + akapit[0].attributes[0]); document.write("</pre>"); </script>
<script> for (var i = 0; i < akapit.length; i++) { document.write("<pre>"); for (var j = 0; j < akapit[i].attributes.length; j++) { document.write("akapit[" + i + "].attributes[" + j + "].name = " + akapit[i].attributes[j].name + "\n"); document.write("akapit[" + i + "].attributes[" + j + "].value = " + akapit[i].attributes[j].value + "\n"); } document.write("</pre>"); } </script>