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

3
  • Is jQuery an option? Commented Nov 7, 2014 at 16:37
  • No, i cannot use JQuery Commented Nov 7, 2014 at 16:39
  • stackoverflow.com/q/4431162/20126 Commented Nov 7, 2014 at 16:42

2 Answers 2

1

Try

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

or

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

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

Sign up to request clarification or add additional context in comments.

Comments

0

Try this,

document.forms[0].children 

You can iterate child elements with

document.forms[0].children[i] 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.