简体   繁体   English

一行显示文字

[英]Text displaying in one line

I have a form which uploads a file. 我有一个上传文件的表格。 After the file is uploaded, I have made a function to display the text inside the uploaded file. 上传文件后,我已经创建了一个功能,可以在上传的文件中显示文本。

However, when the text is presented, it displays in one line. 但是,显示文本时,它显示为一行。 How do I make it do it displays in multiple lines? 如何使其显示在多行中?

 function loadFileAsText() { var fileToLoad = document.getElementById("fileToLoad").files[0]; var fileReader = new FileReader(); fileReader.onload = function(fileLoadedEvent) { var textFromFileLoaded = fileLoadedEvent.target.result; document.getElementById("inputTextToSave").value = textFromFileLoaded; }; fileReader.readAsText(fileToLoad, "UTF-8"); } 
 #inputTextToSave { height: 500px; width: 500px; text-align: left; font-size: 8pt; white-space: nowrap; line-height: 10pt; } 
 <html> <head> </head> <body> <tr> <td>Select a File to Load:</td> <td><input type="file" id="fileToLoad"></td> <td><br><br><button onclick="loadFileAsText()">Load Selected File</button> <td> <td> <div><input type="text" id="inputTextToSave"> </div> </tr> </body> </html> 

The input element can only be used for single line data. input元素只能用于单行数据。 Maybe you want to use the textarea element: 也许您想使用textarea元素:

<textarea id="inputTextToSave" rows="4" cols="50"></textarea>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM