0

Is it possible for me to observe when the HTML has changed inside a <tr> tag?

I can't use jQuery, prototype or any other framework.

As soon as the content changes I need to act on it and stuck how to handle this.

1
  • 3
    This question has been asked many times before. What was unsatisfactory about the answers suggested elsewhere? Commented Nov 25, 2011 at 15:02

2 Answers 2

2

You can monitor the DOM with a timer:

var currentDOM = getCurrentStatus(); // made that up

var timer = setInterval(function() {
  var newDOM = getCurrentStatus();
  if (currentDOM !== newDOM) {
    // do whatever
    currentDOM = newDOM;
  }
}, 100);

That'll check the contents every 100ms. If you have to do a lot of work to figure out whether the DOM has been changed, that might be too fast in that it might make the client machine sluggish.

You can cancel that activity later if you need to:

clearInterval( timer );
Sign up to request clarification or add additional context in comments.

Comments

1

Change detection in terms of plain javascript should be a matter of storing an initial val and checking against that on a time interval. if anyone else knows of a better way, I'd like to hear it. Of course, jquery is powerful for those type of applications, but since you can't use that, I'll stick with my above answer.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.