JS - Issue with selecting childNodes from FireFox

Denisax

New Member
I am currently trying to select the \[code\]childNode\[/code\] of an Element.This is how I am attempting to do so:\[code\]var postBody_elem = elem.parentNode.parentNode.childNodes['post'].childNodes['postBody'];\[/code\]I have also tried:\[code\]elem.parentNode.parentNode.childNodes[0].childNodes[1];\[/code\]I know it is an issue with the \[code\]childNodes\[/code\], not the \[code\]parentNodes\[/code\], I have tested.This is the simplified structure of what I am doing:\[code\]<section id = 'postWrapper'> //This is the Second Parent. <article id = 'post'> //This should be the First Child. <section id = 'postInfo'> <section id = 'postTitle'></section> <section id = 'poster'></section> <section id = 'postDate'></section> </section> <section id = 'postBody'> //This should be the Second Child. </section> </article> <section id = 'postBar'> //This is the First Parent. <img id = 'portrait'> <section id = 'editButton'>Edit</section> //This is the var elem. <section id = 'deleteButton'>Delete</section> </section></section>\[/code\]The reason I have to reference the \[code\]'postBody'\[/code\] by navigating through parent and child nodes is because this format is iterated many times.--This brings me to my issue, the above line of code works in Google Chrome but does not work in FireFox, I have tried many variations but the console gives me the error that it is undefined.I have checked at the element is properly being stated, it is just a difference between the way browsers handle it I presume.If anyone has an answer, I would like it to be on how I can refer to the element that I have shown, not a lecture on how I improperly used \[code\]id\[/code\] for multiple elements, as this is not an issue in this case (to my knowledge, since it works in Chrome).Thanks.
 
Back
Top