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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:31:47+00:00 2026-06-03T22:31:47+00:00

Setup: I have written a jQuery function to update table cells of table_2, when

  • 0

Setup:

I have written a jQuery function to update table cells of table_2, when a row in table_1 is clicked. Here is what I have written:

    <script type="text/javascript">
        $("tr").live('click',function() {
            var host = $(this);
            alert('A row in table 1 is clicked!');

            var count = host.find("td").eq(2).text();
            $("#myTable_2 tr:eq(0) td:eq(1)").text(count);
            $("#myTable_2 tr:eq(1) td:eq(1)").text(5);
        });
    </script>

The Problem:

When I step-through this function using FireBug, I can see the cell data in myTable_2 is being changed. BUT, for every click, the function is executed twice. I can see the alert box appearing twice for each click.

Can somebody tell me why does this happen? And how to avoid this?

  • 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-03T22:31:49+00:00Added an answer on June 3, 2026 at 10:31 pm

    Either of the following:

    1. The clicked row is inside another row (two rows are clicked). (example)
    2. The code you’ve shown is executed twice (example).

    To solve this, make your selector more specific. If you’re using jQuery 1.7+, use .on instead of live: http://jsfiddle.net/6UmpY/3/

    $(document).on("click", "#myTable_1 > tbody > tr", function() {
        // This selector will only match direct rows of the myTable_1 table
    

    Note: Using .on instead of live did not solve the problem.
    Using a more specific selector did fix the issue.
    If you love live, the following would also work: http://jsfiddle.net/6UmpY/4/

    $("#myTable_1 > tbody > tr").live("click", function() {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Debian Linux system setup. I have written various shell script files
I have a few Windows Services written in C# that I have setup to
I have my datepicker set up like this $(#scheduled_date_163).datepicker({ onSelect: function(dateText, inst) { jQuery.get(/tasks/inplace_edit?id=scheduled_date_163&class_name=Task&value=
I have written a function which basically hides the complication of using the pySnmp
I have a strange problem with the jquery plugin and options getting over written.
For an integration test setup, we have written some custom scripts and code to
Hoping someone can give me a hand here.... I have the DataTables jquery plugin
I have written c# application that uses mdf file for database.when i make setup
The Setup: I have a page written in JS that has 3 main divs:
I have written a simple jQuery dialog box that will appear in an asp

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.