IE - how to preserve white space in textarea, inputting with javascript string
FF and Chrome are behaving nicely, but IE 开发者_JS百科(8) is not keeping the white space in my formatted code I'm putting into a TEXTAREA
<textarea id="vdt_table_textarea" style="white-space: pre"></textarea>
and
var vdt_demo_table_string = '<table id="example" class="display">\n\
<thead>\n\
<tr>\n\
<th>Rendering engine</th>\n\
<th>Browser</th>\n\
<th>Platform(s)</th>\n\
<th>Engine version</th>\n\
<th>CSS grade</th>\n\
</tr>\n\
</thead>\n\
etc....
';
$(document).ready(function() {
$('#vdt_table_textarea').html(vdt_demo_table_string.replace(' ', ' '));
});
how can I make IE respect my authoritah?!
CSS
textarea{
white-space:pre;
}
Or
textarea{
white-space:pre-wrap;
}
Not sure why your way doesn't work, but this does:
$('#vdt_table_textarea').html(vdt_demo_table_string.replace(/ /g, ' '));
精彩评论