IE - how to save space in textarea, input using javascript string

FF and Chrome behave nicely, but IE (8) doesn't save a space in my formatted code, which I put in TEXTAREA

<textarea id="vdt_table_textarea" style="white-space: pre"></textarea> 

and

 var vdt_demo_table_string = '&lt;table id=&quot;example&quot; class=&quot;display&quot;&gt;\n\ &lt;thead&gt;\n\ &lt;tr&gt;\n\ &lt;th&gt;Rendering engine&lt;/th&gt;\n\ &lt;th&gt;Browser&lt;/th&gt;\n\ &lt;th&gt;Platform(s)&lt;/th&gt;\n\ &lt;th&gt;Engine version&lt;/th&gt;\n\ &lt;th&gt;CSS grade&lt;/th&gt;\n\ &lt;/tr&gt;\n\ &lt;/thead&gt;\n\ etc.... '; $(document).ready(function() { $('#vdt_table_textarea').html(vdt_demo_table_string.replace(' ', '&nbsp;')); }); 

how can i get IE to respect my authority ??

+4
source share
2 answers

Not sure why your method is not working, but it does:

 $('#vdt_table_textarea').html(vdt_demo_table_string.replace(/ /g, '&nbsp;')); 
+1
source

CSS

 textarea{ white-space:pre; } 

or

 textarea{ white-space:pre-wrap; } 
+6
source

All Articles