http://jsfiddle.net/19gc7pjt/3/
This is not a jQuery problem.
I think this is a javascript related browser issue.
(IE uses '\ r', others use '\ n'. I tested on Chrome btw ...)
You can see exactly the same result in the warning windows. '\ r' is ignored.
$("#ex1").append("\r"); //This one works as expected $("#ex2").append("\n"); //This also works as expected $("#ex3").append("\r\n"); //This also works as expected $("#ex4").append("\r <el></el>"); //This replaces \r with \n $("#ex5").append("\r\n <el></el>"); //This removes \r completely var text4 = "\r <el></el>"; var text5 = "\r\n <el></el>"; alert(text4); //check this alert(text5); //and this $("div").on("click", function () { alert(JSON.stringify(this.innerHTML)); });
source share