编辑下面的代码:【加编码】
<html> <head> <script> function displayResult() { document.getElementById("div1").style.whiteSpace="pre"; } </script> </head> <body> <div id="div1"> This is so me text. This is some tex t. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. </div> <br> <button type="button" onclick="displayResult()">Preserve whitespace and line breaks</button> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂