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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:12:32+00:00 2026-06-04T13:12:32+00:00

I am facing a problem in the jquery click event. actually i was append

  • 0

I am facing a problem in the jquery click event.
actually i was append some tr in table. my code is given below.

HTML CODE:

 <table id="tblList">
            <thead>
                <tr><th>Country Name</th>
                    <th>CityName</th></tr>
            </thead>
            <tbody></tbody>
        </table>

JQUERY CODE:

var rowsCount = $("#tblList tbody").find("tr").length;
var table = "<tr><td>" + countryName + "</td><td>" + cityName + "</td></tr><tr><td colspan='2'><div id='divGridRow'><input type='button' value='add Zip Code' id='btn" + rowsCount + "' class='gridButton'/></div></td></tr>";
$('#tblList').append(table);

above code is working fine. now i want to show dialog when click on my addZipCode button.

i was write below code for get the button id.

 $("#tblList tbody").bind('click', function() {
    $(this).find("tr").bind('click', function() {
        $(this).find("input").bind('click', function() {
            console.log($(this).attr("id"));
        });
    });
});

but still not successful to get button id 100%. In the above code i have face one more issue.
if i click first time on button, no value display in console.log, when click third time,then only one time BUTTON ID is display btn0 and when i click fourth time then button id is display three time
btn0
btn0
btn0

and when i click fifth time then button id is display 6 time atones like this
btn0
btn0
btn0
btn0
btn0
btn0

i append multiple rows in table, and every button in row have a unique id like btn0, btn1,btn2…..
simple i want to try to get button id on click.

please help me to find the solution. Thanks in advance.

please check your self in jsfilddle
http://jsfiddle.net/umairnoor84/y25LW/

  • 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-04T13:12:34+00:00Added an answer on June 4, 2026 at 1:12 pm

    Only bind the click handler on the buttons (elements with the class gridButton).
    Try this:

    $('#tblList .gridButton').click(function() {
        console.log($(this).attr("id"));
    });
    

    === UPDATE ===

    You should append the row not to the table, append it to the tbody of this table:
    Replace

    $('#tblList').append(table);
    

    with

    $('#tblList tbody').append(table);
    

    === UPDATE ===

    Because the rows will be added dynamically, you have to change the code to:

    jQuery 1.7 (here a jsfiddle):

    $('body').on('click', '#tblList .gridButton', function() {
        console.log($(this).attr("id"));
    });
    

    before jQuery 1.7 (here a jsfiddle):

    $('#tblList .gridButton').live('click', function() {
        console.log($(this).attr("id"));
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am facing a problem in the jquery click event. My web page involves
I have code snippet like below I am facing problem when I click on
I'm facing following problem actually: I'm using Spring with jQuery. I have Controller: @Controller
hi im new to jquery and im facing these problem i have these code
I am facing problem on binding jquery event on items created through another action
I am facing a problem with jquery. I have a div with 4 drop
I got this jquery code. And this is some kind of slideshow with fading
I'm looking for a simple & semantic way to code jQuery event handlers that
Guys i am facing a problem with wildcard character in jquery. Please help if
I have a problem with faking an anchor click via jQuery: Why does my

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.