[英]How to create a new line in the output (JavaScript Gui)
For example:例如:
Output.setText("Number of Cars = "+cQuantity
+ "Number of Trucks = " +tQuantity
How would I have the trucks to go on a separate line in the output on the Gui?我如何让卡车在 Gui 的输出中走一条单独的线? Sorry, I am new to coding.对不起,我是编码新手。
You may use the \\n
escape character, or in ES6 you may use template strings:你可以使用\\n
转义字符,或者在 ES6 中你可以使用模板字符串:
console.log('Hello \n World');
console.log(`Hello
World`);
Both of these will yield the same result:这两个都会产生相同的结果:
Hello
World
If you are planning to output the text to html, you could include a <br/>
tag:如果您打算将文本输出到 html,您可以包含一个<br/>
标签:
document.getElementById('element').innerHTML ='Hello<br/>World';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.