0

Is there any event in jQuery when on 'text' goes to a new line.

I need to show a alert box when a text goes to new line in jQuery?

Here is my fiddle.

http://jsfiddle.net/naveennsit/rgeHe/

   setInterval(function () {
       $('#realTimeContents').append("Hiiiii. is div")
   }, 1000); 
putvande
  • 15,068
  • 3
  • 34
  • 50
Rohit
  • 685
  • 3
  • 13
  • 28
  • There's nothing native that does exactly what you want. I'm not sure I would go with setInterval here. I think binding to the keypress event on your element might make more sense, and then checking to see if the height has changed. – Mister Epic Aug 16 '13 at 12:53

1 Answers1

5

How about checking the height of the div on each interval?

$(function() {
  var h = -1;
  setInterval(function () {
    var newHeight = $('#realTimeContents').append("Hiiiii. is div").height();
    if(h == -1) h = newHeight;
    if(h != newHeight) {
        h = newHeight;
        alert("I've changed height");
    }
  }, 1000);
});

Here is a fork of your fiddle.

CodingIntrigue
  • 75,930
  • 30
  • 170
  • 176