Solved

getElementsByClassName on prototype

Posted on 2009-04-02
1
177 Views
Last Modified: 2012-05-06
Hi there,
Completely stuck with a trivial issue i suppose.
I use the prototype library
I have an element and want to get all its child elements with class 'rooms' and do something with each.
What i do is the following code and i get an error el.getElementsByClassName(".rooms").each is not a function
el.getElementsByClassName(".rooms") return an HTMLcollection...How on earth can i manipulate the elements of this collection?

thanks

el.getElementsByClassName('.rooms').each(function(e){

				//do something

			});

Open in new window

0
Comment
Question by:ioustinos_sarris
1 Comment
 
LVL 10

Accepted Solution

by:
cyberstalker earned 500 total points
ID: 24053028
You can loop through all the elements with a for loop
var elements = el.getElementsByClassName('.rooms');
 

for (var i = 0; i < elements.length; i++)

{

    // do something with elements.item(i)

}

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jQuery Parallax 1 38
Angular- another way of coding hide and display 3 41
Jquery get each value 2 17
More SharePoint App with Angular and Bootstrap 17 19
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now