Click here to Skip to main content
15,919,613 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In IE I used to find elements with eachElement.all('elementId')
the result was a coloection of elements with that id.
but in FireFox eachElement.all is undefined.
how can i find elements in a parentNode by their Ids.
thanks.
Posted
Updated 25-Sep-10 0:36am
v2

You could use the property childNodes instead of using all.

Have a look here fr more info:
http://www.w3schools.com/Dom/dom_element.asp[^]

Good luck!
 
Share this answer
 
Comments
Jamal Seyedi 26-Sep-10 2:27am    
First of all. Thanks for your answring.
You know I have a Id string and I want to find specific elements by Id.
ChildNodes give a ListNode so I have to make a loop to find the element.
I want to know whether there is a solution to find some element directily which was supported by javascript?
thanks in advance.
E.F. Nijboer 26-Sep-10 12:14pm    
I personally use FireFox and "all" is still valid when using is as document.all("elementname") but not valid on element level. I think you should use name instead of id to select multiple elements at once with the same name. Instead of using getElementById (which implies only one element is selected) you could use getElementsByName (which you may notice is for selecting multiple elements). Hopefully this will do better.
document.getElementById('elementId') 
works for all browsers.
 
Share this answer
 
Comments
Jamal Seyedi 26-Sep-10 8:15am    
You know I didn't mean that.
I have a table which has some rows and each row has some htmlcontrols and their ids are the same.so now I in each row i nead to find specific control by its id.
for instance instead of document.getElementById('elementId'), HtmlElement.getElementById('elementId')
i am looking for that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900