0

I want to call a function whenever the content in a particular DIV changes. For example:

I have a div. This div displays some data on page load. On another button click, there is some more data displayed in the same div. When data in the div increases, I want to call another function.

Any ideas?

user2598808
  • 633
  • 5
  • 22
  • 40

1 Answers1

0

On another button click, there is some more data displayed in the same div.

On click of that button, check for the content of the DIV. If the content has increased then call your function.

var divContent = $("div#target").text();
$("button").click(function() {
    if(divContent !== $("div#target").text()) { // you can even check for length also
        divContent = $("div#target").text();
        // call your function here
    }
});
mohamedrias
  • 18,326
  • 2
  • 38
  • 47