getElementsByClassName function

Since there doesn’t exist something like a getElementByClassName function, I just tried the js prototype library which has a getElementsByClassName function. You can download it here.

Include it in the head like this:

<script type="text/javascript" src="prototype.js"></script>

Then use it like this:

var test = document.getElementsByClassName("test");

the variable test will be an array.

This entry was posted in JavaScript. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.