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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:31:44+00:00 2026-05-13T16:31:44+00:00

In the program I’m writing I need to be able to access the node

  • 0

In the program I’m writing I need to be able to access the node that is sending an event in javascript.

I have been unsuccessful in using this, as it is referring to the object in my code. So the following doesn’t work.

var node = new node();

// Node Object
function node() {

// Create Sibling Node
this.createSibling = function() {
 var node = createNode();
 this.parentNode.appendChild(node); } }

When I call the function createNode() it assembles a link that has an event onclcick attached to it called node.createSibling() and node.createChild() on a different link.

I’m currently using var NODETREE as the parent because I’m don’t know how to get the node that is begin clicked. This is keeping me from being able to create node with their own children and siblings; only the main node can get them.

    var node = new node();

   // Node Object
   function node() {

   // Instance Veriables    
   var NODETREE = document.getElementById('node-tree');

   // Create Sibling Node
   this.createSibling = function() {
   var node = createNode();
   NODETREE.appendChild(node); } }

How do I access the node that has the onclcick event attached that is being clicked, without having to create a load of code, so I can create children and siblings for the nodes that I have created and not just the trunk?

NOTE:

I need to do this without jQuery or another framework.

  • 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-05-13T16:31:45+00:00Added an answer on May 13, 2026 at 4:31 pm

    When an element has an eventhandler the Event object is passed to the event handler. This event object has amongst other things a reference to the node that triggered the event.

    So…

    var createSibling = function(_event){
      var e = this; // the element this function is actually attached to
      var event_e = _event.target; //another way to get at the element clicked
    
      // do stuff
    };
    
    document.getElementById('myElement').onClick = createSibling;
    document.getElementById('myElement').captureEvents(Event.CLICK);
    

    The problem is the property names for different things differ cross browser – this is another reson to use a framework because they will implement the browser detection ans specific implementations which you will need to do if you do not use one.

    See quirksmode.org for some advanced details: http://www.quirksmode.org/js/introevents.html

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

Sidebar

Related Questions

Program Details: I am writing a program for python that will need to look
I program in Java and have been trying to understand exactly what operator overloading
Program that calculates and shows the value of (2 to the 10th power) This
My program is a game that uses RMI to allow users to connect to
The program that I am working on takes a file and parses it line
Program : List all C files in the current folder using execlp() system call:
My program receives an executable binary file through a TCP socket. I need to
My program needs to receive strings through the serialport. Problem is that the program
I program on Eclipse for Android. But I have a problem with the Android
/*Program to merge to arrays using pointers in descending order, when the first array

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.