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:

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

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.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>