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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:27:51+00:00 2026-05-13T06:27:51+00:00

i see there is this syntax for detecting any button click <script type=text/javascript> $(document).ready(function()

  • 0

i see there is this syntax for detecting any button click

<script type="text/javascript">
        $(document).ready(function() {
        $(":button").click(function(event) {
                alert("Thanks for visiting!" + this.value);
            });
        });
    </script>

but what if i want to only detect a particular button on the page?

EDIT: this seems fine for buttons that are setup at the beginning but in my case i am creating them dynamically with jquery. it seems those buttons dont hit this code. any ideas

  • 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-13T06:27:52+00:00Added an answer on May 13, 2026 at 6:27 am

    You will need to bind “click” to the jQuery “live” function/event for that to work. I would also recommend using either a special CSS class or id on the dynamically generated button. Here is the description of the live even from jQuery.com.

    When you bind a “live” event it will
    bind to all current and future
    elements on the page (using event
    delegation). For example if you bound
    a live click to all “li” elements on
    the page then added another li at a
    later time – that click event would
    continue to work for the new element
    (this is not the case with bind which
    must be re-bound on all new elements).

    <script type="text/javascript">
       $(document).ready(function() {
          //$(":button") would select all buttons
          //.className would work on an button with a CSS Class assignment of ClassName
          //Below shows how to do it on a specific ID
          $("#MyNewButtonID").live("click", function(event) {
             alert("Thanks for visiting!" + this.value);
          });
       });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably just wishful thinking... Is there any way to check to see
Is there any relationship between this aliasing and self type ? Is this aliasing
After a form submit, javascript function is called. JS checks to see if there
My apologies if this question has been asked before. I can see there are
for this site: http://yoursdproperty.com/ do you see how there some extra white space all
If you visit this site , you will see that there is an image
There maybe some simlar questions to this but I can't see anything that really
Please see this IBM site - http://www.ibm.com/us/en/ If you see the site banners, there
You can probably see where I am going with this - but is there
Update: See the bottom of this question for a C# workaround. Hi there, Consider

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.