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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:27:53+00:00 2026-06-05T05:27:53+00:00

how can i retrieve find out which button click is from which div. Basically

  • 0

how can i retrieve find out which button click is from which div.
Basically i have multiple div

<div id="rare1">
<input type=button value="OK" id=btn>
</div>
<div id="rare2">
<input type=button value="OK" id=btn>
</div>
<div id="rare3">
<input type=button value="OK" id=btn>
</div>

i have a function

$("#btn").click(function(){
    $("#rare"+i+" #btn").attr("disabled", "true");
}

this way i can disable the latest button being added.
how can i select which ever button is click on different div id and select the correct btn to disable?

so sorry forget to add something i want to retrieve the div id that clicked the button too.

  • 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-05T05:27:54+00:00Added an answer on June 5, 2026 at 5:27 am

    An id must be uniqe per element per page. Currently you have btn for each button, use a class instead eg class="btn" and then modify your code like this:

    <div id="rare1">
       <input type=button value="OK" class=btn>
    </div>
    <div id="rare2">
       <input type=button value="OK" class=btn>
    </div>
    <div id="rare3">
       <input type=button value="OK" class=btn>
    </div>
    

    JS:

    $(".btn").click(function(){
        $(this).prop("disabled", true);
    }
    

    To get current clicked button, use $(this) as shown in code above.


    Update Based On Comments

    To get parent div id, use:

    $(this).parent().attr('id')
    

    So:

    $(".btn").click(function(){
        var parentId = $(this).parent().attr('id');
        $(this).prop("disabled", true);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a helper function that can retrieve content from a url. This
I have generic list which must be a preserved order so I can retrieve
Is there any way by which i can find out free port on the
Am wondering whether and how i can retrieve a portion of text data from
I am attempting to write a script that can retrieve the HTML from my
Possible Duplicate: get all available fonts from google font api How we can retrieve
I am trying to find out how I can tell if a user has
These are two type of string I can get in input: String mex1 =
I'm trying to figure out how to retrieve the stream which a given view
how i can retrieve the list of friends and their details (photo, name and

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.