Imagine this codes:
<div id="layer1" style="position:absolute; width:....."> This is some text <BR> and this is a new line </div>
you will be given the output of:
This is some text and this is a new line
simple right?
But unfortunately, <BR> can't be use to append a line break or a new line in a sentence, dynamically, using innerHTML or textContent:
<script> document.getElementById('layer1').innerHTML = "This is some text <BR> and this is a new line" </script>
<div id="layer1" style="position:absolute; width:....."> no text yet </div>
It will give you:
This is some text and this is a new line
So how to overcome this?
Just use "\n" instead :D
<script> document.getElementById('layer1').innerHTML = "This is some text \n and this is a new line" </script>
Thursday, July 19, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment