When I create a new element and I start typing (with the contentEditable set to true), and then look at it's innerHTML, it always contains an extra <br>
at the end. If I look at the innerHTML before typing, I am getting the correct value. Is this normal? My problem is that I'm counting the number of lines using the <br>
tag, and I can't have it give me more than I need. Here is some test code (javascript):
var _this = this;
function keyup(event)
{
if (event.keyCode == 112)
{
alert(_this.code.innerHTML);
}
}
function create()
{
this.code = document.createElement("div")
this.code.innerHTML = "Hello world.<br>I like testing popcorn.<br>Testing again.";
this.code.contentEditable = "true";
this.code.onkeyup = keyup;
document.body.appendChild(this.code);
_this = this;
}
window.onload = function()
{
create();
}
The code is set up so when you press F1, it shows the contents of div. I am using the latest version of Firefox.