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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:18:04+00:00 2026-05-25T20:18:04+00:00

I was wondering how I’d go about finding with jQuery, the element id that

  • 0

I was wondering how I’d go about finding with jQuery, the element id that called an onClick method? my code is:

JS

function getInfo(event)
{
    console.log(event.target.id + " ... ");
}

HTML

<div class="menu-content" id="thisismyid">
    This is some placeholder text.<br>
    <a onClick="getInfo()" id="thisisthelinksid">Click on me</a>
</div>

<div class="menu-content" id="thisismysecondid">
    This is some more placeholder text.<br>
    <a onClick="getInfo()" id="thisistheotherlinksid">Click on me</a>
</div>

I can’t put anything inside the parentheses of the function, because I want a function passed to it later, I just want to be able to tell which called this function.

I know this has been asked many times, and a lot of the questions have answers, but I have read through a lot of them and none have helped me.

Thanks guys

-EDIT-

In regards to the answers below at time of this edit, I cannot use the jQuery method like:

$("div.menu-content a").click(function() {
    some content here..
});

because I need it to only be run on certain links being clicked, not all of them. Does that help clarify?

  • 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-25T20:18:05+00:00Added an answer on May 25, 2026 at 8:18 pm
    $("div.menu-content a").click(function() {
        var $elemId = $(this).attr("id");
        console.log($elemId + " .... ");
    );
    

    Is a much more “jQuery style” solution to do it.

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

Sidebar

Related Questions

Wondering if this is possible. We have an 3rd Party library that contains identification
Wondering if there is any way to get the lambda expressions that result from
Wondering why a particular binary write operation in VB is so slow. The function
Wondering if there is any way to build and fire an event (e.g. on
Wondering if anyone knows how to achieve a typewriter effect with the jQuery Cycle
wondering what is the major difference between these two: onClick and mouseClick..
Wondering what are the views on this We have a CI server that runs
Wondering what the point of if (self = [super ... in the following code
wondering if there's any way to make it so that a list I have
Wondering if someone can answer something that has stumped me. I have a Timer

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.