tags:

views:

23

answers:

3

Is there a way to get ElementById within a DIV.

Problem is on a Webpage I have 25 DIV and each of them contains a hidden DIV with same IDs.

+4  A: 

They're not allowed to have the same ID (see http://bytes.com/topic/javascript/answers/151190-how-reference-id-more-elements-same-id for a discussion). Your webpage's HTML is malformed. There's no way around it. Try changing the ID's to classes.

MvanGeest
A: 

There is no way around cause your html is wrong. An ID is a unique identifier so it can only be one on your page. Dependent on your browser you will get the first or last of your divs with the same id.

eskimoblood
+1  A: 

You are only allowed 1 instance of an ID per page, insted use classes.

Adam
Indeed - with non-unique IDs, the behavior is undefined.
Piskvor