Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8933925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:39:48+00:00 2026-06-15T09:39:48+00:00

I am currently trying to select the childNode of an Element. This is how

  • 0

I am currently trying to select the childNode of an Element.
This is how I am attempting to do so:

var postBody_elem = elem.parentNode.parentNode.childNodes['post'].childNodes['postBody'];

I have also tried:

elem.parentNode.parentNode.childNodes[0].childNodes[1];

I know it is an issue with the childNodes, not the parentNodes, I have tested.

This is the simplified structure of what I am doing:

<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>

The reason I have to reference the 'postBody' 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 id for multiple elements, as this is not an issue in this case (to my knowledge, since it works in Chrome).

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:39:49+00:00Added an answer on June 15, 2026 at 9:39 am

    The first method does not work in Firefox because it seems to be non standard, the second one doesn’t work because you didn’t realize that childNodes also consist text nodes. To get the element you want try

    elem.parentNode.parentNode.childNodes['1'].childNodes['3']
    

    http://jsfiddle.net/mowglisanu/UqZVn/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to use this query SELECT a.id AS id, a.item AS item,
The MySQL query I'm currently trying to perform is functionally equivalent to this: SELECT
I'm currently trying to select the previous closest list element within an <ul> My
I have a following question. We are currently trying to select an appropriate structure
I am currently trying to make a game in Android. I have this piece
I'm currently trying to copy data from table into another by using a SELECT
I currently am trying the following code: $sql = $db->query(select id,username,fullname from userss ORDER
I'm currently trying to create a page for users to select two points from
I'm currently trying to understand some of the fundamentals with LINQ. I have been
I am currently trying to create a html:select tag from an enum so it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.