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

  • Home
  • SEARCH
  • 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 979135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:10:21+00:00 2026-05-16T04:10:21+00:00

The following codes don’t work: function dnd(){ } var ele = document.getElementById(relative); ele.addEventListener(click,dnd,false); document.write(ele.onclick);

  • 0

The following codes don’t work:

function dnd(){
}
var ele = document.getElementById("relative");
ele.addEventListener("click",dnd,false);
document.write(ele.onclick);

the output is undefined. I guess the output should be function onclick(event){dnd();}

What should I do to solve this problem?

Any suggestion is appreciated.

  • 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-16T04:10:22+00:00Added an answer on May 16, 2026 at 4:10 am

    There are 3 common ways to attach events to DOM nodes.

    The addEventListener() method is the way to register an event listener as specified in W3C DOM. It has many benefits, but doesn’t work in Internet Explorer. For Internet Explorer you’d have to use the attachEvent() method, which offers similar functionality.

    On the other hand, the onclick property is an older, but more supported way to attach event handlers. However it has certain disadvantages, such as allowing just one event handler for each event.

    As for how to get back the event handlers that are attached to a particular node, it depends on the method you use to attach the events. The problem with your example is that you’re using the addEventListener() method to attach the event, and then trying to read it using the onclick property.

    You may want to check out the following Stack Overflow post for further reading into this topic, especially the post by @Crescent Fresh:

    • How to find event listeners on a DOM node?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a notification system that works with the following codes jQuery: $(document).ready(function(){$.get('/codes/php/nf.php', function(data)
The following code don't work- TextView myLocation = new TextView(this); myLocation.setText(Sodala, Jaipur, Rajasthan, IN);
In the following code I want to use the dilate function but I don't
The following source code are used to implement product/consumer pattern, but they don't work
I have the following sample codes. I don't like to have lTest being captured
I understand the following codes: function subtract(p1, p2) { return p1 - p2; }
I am trying to understand someone else's codes...he has the following: var positionAt =
I came across following code and don't know what does having from twice mean
The following code crashes and burns and I don't understand why: DateTime dt =
The following code produces the result I don't understand this. Any ideas why? If

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.