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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:06:28+00:00 2026-05-25T00:06:28+00:00

This should be basic, but for some reason its not working for me. I

  • 0

This should be basic, but for some reason its not working for me. I just want to store the id when a link that has a certain class is clicked in a variable so as an example:

<a href="#" id="this_id_here" class="only_this_class">Some link</a>

I would want jquery to get the id of the link above and store it in a variable. I have tried $this.attr(“id”) and $this.id, but non of this worked.

This is what I have for the jquery:

  $(".only_this_class").click(function() {

      var clickedId= $(this).attr("id");
      alert(clickedId);
   });

I just get “undefined” every time.

  • 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-25T00:06:29+00:00Added an answer on May 25, 2026 at 12:06 am

    I removed the space between this and _class in class="only_this _class" and it is working for me.

    Try this here

    Please have a look at jQuery Selectors

    If you have two classes in your HTML then the syntax is different:

    $('.classA.classB')
    

    Have a look at How can I select an element with multiple classes?

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

Sidebar

Related Questions

This should be a very basic design question, but for some reason it doesn't
This should be a really really simple thing, but for some reason it is
I'm pretty sure this is a basic question but for some reason i can't
I'm pretty sure this is a basic question but for some reason i can't
This is probably the MOST basic question and for some reason but I'm a
I know this should be a basic question but I am hitting a brick
I'm trying to learn this basic thing about processors that should be taught in
This should be easy for many of you, but for me it's just another
This should be easy, but I'm not sure how to best go about it.
What I want to do is implement some basic security by checking not only

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.