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

Ask A Question

Stats

  • Questions 495k
  • Answers 496k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer When you add service reference it by default creates new… May 16, 2026 at 11:31 am
  • Editorial Team
    Editorial Team added an answer I think you have to 1) Change the cascade setting… May 16, 2026 at 11:31 am
  • Editorial Team
    Editorial Team added an answer When you say "reporting service" I suppose you mean "report… May 16, 2026 at 11:31 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Is there a way this hand coded query could become dynamic? SELECT master.id, (select
I can see there's a sorting object, Sorting , with a quicksort method, quickSort
I'm trying to save data with following structure: As you can see, there is
I get confused when I see examples of self invoked anonymous functions in Javascript
My dev environment is LAMP-based (Drupal); there are several JS (jQuery) files that are
The only php page that I see with the code is the index.php, so
Possible Duplicate: Is there a difference in C++ between copy initialization and assignment initialization?
Mysql errors are among the most common ones you see during development, and I
I am trying to call the function MyMethod from within a object but none
I have been able to create php function to determine a list of zip

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.