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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:51:51+00:00 2026-06-11T22:51:51+00:00

I have a simple Jquery script which populates an empty table with lots of

  • 0

I have a simple Jquery script which populates an empty table with lots of rows and cells.

Depending on the state of a checkbox I want to toggle a CSS class for all cells within the newly populated table (not there when the page loads, but dynamically created by a JS function upon a form submit).

I am able to set up a “click” event on the table cells and it works fine.

But my attempts at using on() to bind a function to a hover() event have not been successful. The event never seems to get triggered and no console log message produced. Any ideas about what I’m doing wrong?

$("#resultTable").click(function(e){  // This function works fine.
        $(e.target).closest('td').toggleClass('stay');
    });

$("#resultTable td").on("hover", //Same problem for a simpler 'mouseover'
    function(event){
        console.log("MOUSE OVER"); //Never appears
        $(this).toggleClass('over');
    },
    function(event){
        console.log("MOUSE OUT"); //Never appears
        $(this).toggleClass('over');
    }
    );
  • 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-11T22:51:52+00:00Added an answer on June 11, 2026 at 10:51 pm

    If you are dynamically inserting rows into the table then .on will not work if its binded to the tds that come into existence after the binding happens. From the docs When the call to .on is made the element to which the event is binded must exist in the DOM when the binding happens.

    Event handlers are bound only to the currently selected elements; they must exist on the page at the time your code makes the call to .on().

    This might work

    $j(document).on("hover", "#resultTable td",
        function(event){
            console.log("MOUSE OVER"); //Never appears
            $(this).toggleClass('over');
        },
        function(event){
            console.log("MOUSE OUT"); //Never appears
            $(this).toggleClass('over');
        }
        );
    

    If you are only adding the rows dynamically then you can attach the event to #resultTable to make the delegation a bit faster.

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

Sidebar

Related Questions

I have a very simple jQuery script.. all I want it to do is
I have a JQuery script which acts as a simple image rollover with a
I have this very simple jQuery script, which gives me error that delay is
I think this is quite simple. I have a working AJAX Jquery script which
I have a simple jQuery script which pushes the footer to the bottom of
I have a really simple jQuery script which when an input element is focused
I have a simple jQuery script that I'm trying to build upon but I
I have created a simple JQuery script with hovering effect on some links. The
I have this simple function: <script type=text/javascript> //<![CDATA[ jQuery(function($){ function here(b){alert(b);} ; here(6); });
I have a simple jquery animation on a div, which is inside a div,

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.