<!DOCTYPE html>
<html>
<body>
<p>p tag 1</p>
<p>p tag 2</p>
<button onclick="ElementsByTagNameTest()">Elements By Tag Name Test</button>
<script>
function ElementsByTagNameTest()
{
var all_tags = document.getElementsByTagName("*");
var s;
for (i = 0; i < all_tags.length; i++)
s = s + all_tags[i].toString() + "<br />";
document.write(s);
}
/*
run:
undefined[object HTMLHtmlElement]
[object HTMLHeadElement]
[object HTMLBodyElement]
[object HTMLParagraphElement]
[object HTMLParagraphElement]
[object HTMLButtonElement]
[object HTMLScriptElement]
[object HTMLParagraphElement]
http://localhost:8080/test.html
[object HTMLUListElement]
[object HTMLLIElement]
[object HTMLParagraphElement]
*/
</script>
<p>p tag 3</p>
<a href="#">a tag</a>
<ul>
<li>li tag</li>
</ul>
</body>
</html>