[Javascript] Need to loop through all element in a div cross browser
Hakan M (Backbase)
hakan at backbase.com
Thu Dec 9 11:42:25 CST 2004
No problem. I suppose by "cross browser" you mainly mean IE and browsers
that follow DOM standard. For Mozilla, you can check out the Gecko DOM
reference at
http://www.mozilla.org/docs/dom/domref/
I think you'll find most methods and properties you need in
http://www.mozilla.org/docs/dom/domref/dom_el_ref.html
Standard DOM operations should work the same way in Opera and Safari,
but if you run into problems just ask away.
H
Laurent Muchacho wrote:
> Hi
>
> Thanks this this give an other approach to what I have to do
> Thanks a lot Hakan.
> Do you have any references link, url you could recommend on this.
>
> Thanks Laurent
>
> -----Original Message-----
> From: Hakan M (Backbase) [mailto:hakan at backbase.com]
> Sent: 09 December 2004 16:35
> To: [JavaScript List]
> Subject: Re: [Javascript] Need to loop through all element in a div
> cross browser
>
>
> Something like this:
>
>
> var oDiv = document.getElementById('parentDiv');
> if(oDiv.firstChild) { // check for children
> var oChild = oDiv.firstChild;
> while(oChild) { // run over them
> if(oChild.nodeType==1) { // element
> // oChild is a first level child of oDiv
> // Do what you want with it here
> }
> oChild = oChild.nextSibling;
> }
> }
>
>
> Didn't try it, but you get the point.
>
> Regards,
> H
>
>
> Laurent Muchacho wrote:
>
>>Hi All,
>>
>>Guy's I seriously need your help.
>>What I'm trying to do is a loop through all element first level nested
>>contained in a DIV.
>>The Idea is to reproduce the document.all implemented by IE but cross
>>browser.
>>Please if you think it's impossible please reply and let me know.
>>
>>Found below an examples of my html
>>
>><div id="parentDiv">
>> <input type="text" name="test1" value="">
>> <input type="text" name="test2" value="">
>> <input type="text" name="test3" value="">
>> <input type="text" name="test4" value="">
>> <input type="text" name="test5" value="">
>> <select name="select1">
>> <option>test 1</option>
>> <option>test 1</option>
>> <option>test 1</option>
>> <option>test 1</option>
>> </select>
>> <div id="childDiv1">
>> don't want to count the item nested in this element
>> <input type="text" name="childDiv1test1" value="">
>> </div>
>> <div id="childDiv2">
>> don't want to count the item nested in this element
>> <input type="text" name="childDiv2test1" value="">
>> </div>
>></div>
>>
>>Thanks in advance.
>>
>>Laurent
>>_______________________________________________
>>Javascript mailing list
>>Javascript at LaTech.edu
>>https://lists.LaTech.edu/mailman/listinfo/javascript
>>
>>
>
>
--
Hakan Magnusson
Senior Software Engineer
E. hakan at backbase.com
M. +31 (0)6 430 40 112
BACKBASE BV
Stephensonstraat 19
1097 BA Amsterdam
W. http://www.backbase.com/
T. +31 (0)20 750 7305
F. +31 (0)20 750 7301
# Winner of the Broos van Erp Prize (Best High Tech Starter 2004)
# Winner of Golden SPIN Award (Innovation Prize 2003)
More information about the Javascript
mailing list