Hi all,
I have a question regarding displaying a string in javascript. Ok, I have a collection of string in a variable and i am iterating it through a loop for display. Each string has spaces that seperate column 1 from column 2, but both columns are in one string. For example:
This is my string 1Also my string 1.
This is my sring 2Also my string 2.
Where = empty white space.
The problem is, when it display in the brower (in my html table), all the spaces get striped off. So, it looks like this:
This is my string 1 Also my string 1.
This is my string 2 Also my string 2.
I don't understand why it does that. Is it because of javascript?
How would i go about in displaying the string the way it suppose to look?
Please replay. Thanks.
Comments
:
: I have a question regarding displaying a string in javascript. Ok, I have a collection of string in a variable and i am iterating it through a loop for display. Each string has spaces that seperate column 1 from column 2, but both columns are in one string. For example:
:
: This is my string 1Also my string 1.
: This is my sring 2Also my string 2.
:
: Where = empty white space.
: The problem is, when it display in the brower (in my html table), all the spaces get striped off. So, it looks like this:
:
: This is my string 1 Also my string 1.
: This is my string 2 Also my string 2.
:
: I don't understand why it does that. Is it because of javascript?
: How would i go about in displaying the string the way it suppose to look?
:
: Please replay. Thanks.
:
Normal space characters (#32) are always compacted to 1 space by browsers. It is part of the HTML specification. To get multiple spaces after each other use the "non breaking space" code: " ".