1

I have a line of javascript code that works perfect in IE

document.forms[0].all

what it does, it gets all the dom elements including their child elements.

I want this same in chrome, i used this:

document.forms[0].childNodes

what it does, It gets all the dom elements but not their childs

So, my question is how to achieve the same functionality for chrome?

Thanks

Siraj Hussain
  • 69
  • 2
  • 11

2 Answers2

1

Try

document.forms[0].getElementsByTagName('*')

or

document.forms[0].querySelectorAll('*')

This won't give you text nodes, but DOM elements you will get.

Yuriy Galanter
  • 36,794
  • 12
  • 65
  • 122
0

Try this,

document.forms[0].children

You can iterate child elements with

document.forms[0].children[i]
Sampath Liyanage
  • 4,618
  • 25
  • 40