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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:56:07+00:00 2026-06-11T06:56:07+00:00

I have a problem: I have table that is updated from time to time

  • 0

I have a problem: I have table that is updated from time to time by AJAX script. This update is called from Chrome plugin which I don’t want to change. So I’d like to add some kind of jQuery trigger that on change of table cells will call my own function.

Is it possible? I tried event onChange but it doesn’t work (it’s for input if I’m right)

Thanks in advance!

  • 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-11T06:56:09+00:00Added an answer on June 11, 2026 at 6:56 am

    onchange is designed for use with inputs like <select> – so wont work in this context. There are specific dom related events you can use (like DOMSubtreeModified), but these aren’t cross-browser and have varying implementations (they may even now be deprecated):

    http://en.wikipedia.org/wiki/DOM_events

    MutationEvents as mentioned above have seemingly been replaced by MutationObservers which I have not used yet myself… but sounds like it would do what you need:

    http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#mutation-observers

    setInterval

    Other than that you can fallback to a setInterval handler that will listen for any change in the HTML within your target element… when it changes you fire a function.

    function watch( targetElement, triggerFunction ){
      /// store the original html to compare with later
      var html = targetElement.innerHTML;
      /// start our constant checking function
      setInterval(function(){
        /// compare the previous html with the current
        if ( html != targetElement.innerHTML ) {
          /// trigger our function when a change occurs
          triggerFunction();
          /// update html so that this doesn't keep triggering
          html = targetElement.innerHTML;
        }
      },500);
    }
    
    function whenChangeHappens(){
      alert('this will trigger when the html changes in my_target');
    }
    
    watch( document.getElementById('my_target'), whenChangeHappens );
    

    jQuery Plugin

    If you want to jQueryify the above into something you can apply to any element it would easy to modify:

    /// set up the very simple jQuery plugin
    (function($){
      $.fn.domChange = function( whenChanged ){
         /// we want to store our setInterval statically so that we
         /// only use one for all the listeners we might create in a page
         var _static = $.fn.domChange;
         _static.calls = [];
         _static.iid = setInterval( function(){
           var i = _static.calls.length;
           while ( i-- ) {
             if ( _static.calls[i] ) {
               _static.calls[i]();
             }
           }
         }, 500 );
         /// step each element in the jQuery collection and apply a
         /// logic block that checks for the change in html
         this.each (function(){
           var target = $(this), html = target.html();
           /// by adding the function to a list we can easily switch
           /// in extra checks to the main setInterval function
           _static.calls.push (function(){
             if ( html != target.html() ) {
               html = target.html();
               whenChanged();
             }
           });
         });
      }
    })(typeof jQuery != undefined && jQuery);
    
    /// example code to test this
    (function($){
      $(function(){
        $('div').domChange( function(){
          alert('I was changed!');
        } );
      });
    })(typeof jQuery != undefined && jQuery);
    

    Obviously the above is a very simple version, it should be extended to handle adding and removing of listeners.

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

Sidebar

Related Questions

I have a big problem. I want to extract text from html table that
Problem: I have a table that prints out vertical but I would like it
Here is the problem: I have two columns in a table that, for each
Screenshot mockup: http://tinypic.com/r/y2qex/5 Problem: I have a table that has 53 columns; one for
that my problem: I have database table like that: id (AI) market_id 1 6
I have a table that is split into 3. My problem is I have
I have a class that is mapped to a table using NHibernate. The problem
I have a table with more than 1 million records. The problem is that
A short description: I have a table with data that is updated over a
I have a table (InnoDB) that gets inserted, updated and read frequently (usually in

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.