This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes lost space after setting innerHTML Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply 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?
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: lost space after setting innerHTML
 
Similar Threads
3 questions about javascript
Pass values from pop up window to parent window using jsf
Unable to print embedded word document
Updating content with javascript
Sound multiplies with clicks?