aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes lost space after setting innerHTML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "lost space after setting innerHTML" Watch "lost space after setting innerHTML" New topic
Author

lost space after setting innerHTML

Kevin Tysen
Ranch Hand

Joined: Oct 12, 2005
Posts: 255
When you have some code like this:
<span>I</span><span> love</span><span> her.</span>
The web page looks like this:
I love her.
But if the code looks like this:
<span>I</span><span id="lovespan"></span><span> her.</span>
And then you have a code line in JavaScript like this:
document.getElementById("lovespan").innerHTML=" love";
The web page looks like this:
Ilove her.
When changing the innerHTML, the space at the beginning of the word " love" is dropped. I could do this:
document.getElementById("lovespan").innerHTML=" love";
But I want the word "love" to wrap to the next line if need be. Any ideas on how to display "I love her." by setting the innerHTML?
 
Don't get me started about those stupid light bulbs.
 
subject: lost space after setting innerHTML