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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:22:30+00:00 2026-06-17T10:22:30+00:00

RawClicked I have old assign method of tr for event like this: <tr ondblclick="RawClicked(this)

  • 0

RawClicked I have old assign method of tr for event like this:

<tr ondblclick="RawClicked(this) .......

and I want to attach the event in JavaScript code like this, and delete assigning the event handler in HTML tag <tr .... > :

var element = document.getElementById("CustomersTable").getElementsByTagName("tr");
AssigningEventHandles(element, "dblclick", RawClicked(this));

function AssigningEventHandles(element, event, handler) {
    if (element.addEventListener) {
        element.addEventListener(event, handler, false);
    }

    else if (element.attachEvent) {
        element.attachEvent("on"+ event, handler);
    }
}


function RawClicked(raw) {
    var rawDoubleClicked = raw.id;
    alert(rawDoubleClicked);
}

So how can I pass the parameter this to the function in this case?

  • 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-17T10:22:32+00:00Added an answer on June 17, 2026 at 10:22 am
    1. In your example element is a collection of nodes, not a single element, so you can’t add event listeners this way. You may iterate over this collection of nodes or use event delegation and attach event listener to the <table>.

    2. In this line AssigningEventHandles(element, "dblclick", RawClicked(this)); RawClicked is executed with this bound to the global object. So the argument passed as handler to AssigningEventHandles is the result of this function, which is void. You should pass the function like this: AssigningEventHandles(element, "dblclick", RawClicked); and then use this.id instead of raw.id in RawClicked.

    Fixed code:

    var element = document.getElementById("CustomersTable").getElementsByTagName('tr');
    AssigningEventHandles(element, "dblclick", RawClicked);
    
    function AssigningEventHandles(element, event, handler) {
      if( !element.length ){ /* convert to array if it's a single node */
        element = [element];
      }
      for( var i=0; i<element.length; i++){ /* iterate over nodes and attach event listeners */
        if (element[i].addEventListener) {
            element[i].addEventListener(event, handler, false);
        }
    
        else if (element[i].attachEvent) {
            element[i].attachEvent("on"+ event, handler);
        }
      }
    }
    
    function RawClicked() {
    /* `this` is bound to the clicked element */
        var rawDoubleClicked = this.id;
        alert(this);
    }
    

    http://jsfiddle.net/WU76d/

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

Sidebar

Related Questions

I'm attempting to have an onclick event added to a row once the data
I have a flash file in a div. This div is set to visible
I have a view in Silverlight which contains a telerik:RadGridView with a number of
I have an application which has a tabbar to navigate through 5 views. I
I have a TableLayout in the xml that has a row. I am adding
Here is a code of my toolbar: JS_TOOLBAR_BUTTON = 0 JS_TOOLBAR_SEPARATOR = 1 JS_TOOLBAR_MONTHCONTROL
I'm trying to disable an image map onClick - and eventually I'd like to
I am new here. I am trying to store a JavaScript variable in a
Outline My simple application takes text from a text box and calls an asp.net
is there any way by which I can change an id type to NSString

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.