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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:41:54+00:00 2026-06-17T17:41:54+00:00

I have, <div> <span>Buttons</span> <div> <button id ="button_1" class="button">Btn 1</button><br /> <button id ="button_1"

  • 0

I have,

<div>
  <span>Buttons</span>
    <div>
      <button id ="button_1" class="button">Btn 1</button><br />
      <button id ="button_1" class="button">Btn 2</button><br />
      <button id ="button_3" class="button">Btn 3</button><br />
      <button id ="button_4" class="button">Btn 4</button><br />
    </div>
  <span>Checkboxes</span>
  <div>
    <input type="checkbox" /> Chbx 1<br />
    <input type="checkbox" /> Chbx 2 <br />
    <input type="checkbox" /> Chbx 3 <br />
  </div>
</div>

How do I determine which button/checkbox has been clicked? I could attach a click event to each button but I’m looking for any method/tricks you might have that’s a bit more efficient.

  • 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-17T17:41:55+00:00Added an answer on June 17, 2026 at 5:41 pm

    You can attach a click to ALL buttons and inputs and check the tagName, ID etc..

    $(document).on('click', 'input, button', function(event) {
        alert(this.tagName + '#' + this.id);     
    });
    

    NOTE: You can attach the event to just the document element and check event.target to achieve the same, but the above is more efficient as the callback will be fired only for inputs and buttons instead of for all elements.

    See Demo: http://jsfiddle.net/vCjn9/

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

Sidebar

Related Questions

I have a dropdown menu: <div class=buttons> <div class=dropdown> <a href=# class=button><span class=label>File</span><span class=toggle></span></a>
In web-code I have a button: <div id="net-equipment-button_config-1037" class="x-btn x-box-item x-toolbar-item x-btn-default-small x-noicon x-btn-noicon
var text = $(this).text(); alert(text); Afterdata = "<div><span><input type=text class=inputtext value="+text+">"+ "</span>" + "<span
I have a problem with stylize buttons in bootstrap. <div class=btn-group> <button class=btn btn-midd>Link</button>
Here is the html that I have: <div id=top> <span id=title>Some Title</span> <span id=buttons><button>Bla</button><button>Foo</button></span>
I have two div containers: <!-- button1 --> <div class=voted> <span>name</span> <div class=button>Vote</div> </div>
I have been trying to style an input type="file" field. My button is styled
I have a div with a span <div id=div1> <span class=>hello</span> </div> When i
I have <span> inside a <div> , like so: <div id=#mydiv> <a href=#>Hello</a><span class=myImageArea></span>
i have the following code <div class=hitarea expandable-hitarea></div> <span class=folder>level 1</span> <ul style=display: none;>

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.