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 8248997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:23:06+00:00 2026-06-07T23:23:06+00:00

I am trying to access the parentNode of a button element (div) but I

  • 0

I am trying to access the parentNode of a button element (div) but I get an error every time. Here is what I am trying to do. Simply put, this is a page that had 2 divs on it. I only want one div displayed at a time. There is a button on the first page that switches to the second and a button on the second that is supposed to return to the first (but doesn’t because it can’t locate the parentNode).

        <div class="pageContent" id="page_3">
            <div class="primaryPage" id="primaryPage_3">
                <h2>Bills_______________________</h2>
                <p>Here are my monthly Bills<br><br>blah blah</p>
                <button type="button" id="billButton" onclick="newBill()">Add Bill</button>
            </div>
            <div class="pageContent" id="billPage">
                <p>this is the bill page</p>
                <button class="backButton" onclick="back()">Back</button>
            </div>
        </div>

function newBill(){
document.getElementById("primaryPage_3").style.display = "none";
document.getElementById("billPage").style.display = "block";
document.getElementById("billPage").setAttribute("back", "primaryPage_3");
}

function back(){
var previousPage = this.parentNode.getAttribute("back");
this.parentNode.style.display = "none";    
document.getElementById(previousPage).style.display = "block";
}
  • 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-07T23:23:08+00:00Added an answer on June 7, 2026 at 11:23 pm

    Change this…

    onclick="back()"
    

    to this…

    onclick="back.call(this)"
    

    Invoking a function using .call() lets you manually set the calling context (the this value) of the function being invoked. Here it’s setting it to the current element.

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

Sidebar

Related Questions

I'm trying to access the parentNode of an element found with preg_match, because I
When trying to access the following URL, I get a 404 error page :
I am trying to access child nodes of a root element but I am
I am trying to access a specific element of the Dom using XPath Here
Trying to access a Servlet from a button on HTML page //Html Page FORM
I am trying to access a file for xml parsing with this: InputStream inputStream
Hi I am trying to get the HTML of INPUT tag. But unable to..
Trying to access github using the following command fails with the verification failed error.
I'm trying to access YouTube from within an iOS app, but the iOS SDK
i cannot get current content page html. when i trying access from script in

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.