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

The Archive Base Latest Questions

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

I have the following code: Html: <tr> <td onclick=ThingClicked()>click me</td> </tr> JS: function ThingClicked(event)

  • 0

I have the following code:

Html:

<tr>
    <td onclick="ThingClicked()">click me</td>
</tr>

JS:

function ThingClicked(event) {
    var row = event.currentTarget.parent("tr");
    callAnotherDOMManipulatingFunction(row);
}

For some reason, event.currentTarget is undefined. I tried ‘this’ but that was undefined aswell. What’s going on? How do I get the row that this td is contained in?

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

    Well, since you included a jQuery tag (and included a link to jQuery docs), I’ll show you how that way.

    EDIT:

    jQuery live() docs

    jQuery clone() docs

    EDIT: Added jQuery’s ready() function. You will always place your code inside as shown.

    $('document').ready(function() {
        $('td').click(function() {
            var row = $(this).closest('tr');
            callAnotherDOMManipulatingFunction(row);
        });
    });
    

    Of course, this will attach a click event to every td tag, but you get the idea.

    EDIT:

    Further explanation. When using jQuery, you typically will assign events in your javascript, not in HTML. Assigning to ‘td’ will give the click event to every ‘td’ tag on the page, so it may be that you will instead give the ‘td’ a class and use that to attach the event, like:

    $('.myFreakingAwesomeClass').click(function() {
        ...
    });
    

    You won’t often need to reference ‘event’, but it does come in handy at times.

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

Sidebar

Related Questions

I have the following piece of code <a onclick=$('#result').load('codes/test.html');$('#result').show(); >XHTML code</a> it loads perfectly
I have the following JavaScript code: function createNotification(title, body, canDismiss, callback) { //create the
I have the following code to perform validation of SubmitForm shown below on click
I try to make a common solution for the following task: onclick event listener
Hi guys lets say I have the following html: <div class=owner> <div> <a href=javascript:void(0)
I have a button named okbutton. A callback function is bind to the click
i have the following code for search from database show return result to the
I have the following code i am trying to change the font of a
I have the following files: view.jsp <@ page import=... <bean:define id=mForm name=myForm type=MyForm/> <html:form
I am absolutely new to the Android platform and have been building an application

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.