-2
  $('.val').text().change(function(){ /*Do something */ }); // something like this

Do something when div text is changed. How to get div text element?

josaric
  • 25
  • 4

1 Answers1

0

you can detect using DOMSubtreeModified event like this :

$('.val').on("DOMSubtreeModified",function(){
  alert('changed');
});

DEMO FIDDLE

Ehsan Sajjad
  • 61,834
  • 16
  • 105
  • 160
  • _Be very careful with this event it is easy to cause an infinite loop if you decide to change the DOM inside the event handler._ – Jai Jul 01 '14 at 09:46
  • Works, thx :) sry for bad title, it's difficult to explain it or for duplicate, couldn't find it :/ – josaric Jul 01 '14 at 09:48
  • @Jai please explain more about it what you are talking about – Ehsan Sajjad Jul 01 '14 at 09:55
  • 1
    @EhsanSajjad its in the documentation @ [MDN here.](https://developer.mozilla.org/en-US/docs/Web/Events/DOMSubtreeModified) – Jai Jul 01 '14 at 10:16