在JavaScript中,writeln的意思是“換行輸出”,用于向文檔寫入HTML表達式或JavaScript代碼,并且在每個表達式后寫一個換行符,語法為“document.writeln(exp1,exp2,exp3,….)”。
本教程操作環(huán)境:windows10系統(tǒng)、javascript1.8.5版、Dell G3電腦。
javascript中writeln的意思是什么
write() 方法可向文檔寫入 HTML 表達式或 JavaScript 代碼。
可列出多個參數(shù)(exp1,exp2,exp3,…) ,它們將按順序被追加到文檔中。
writeln() 方法與 write() 方法作用相同,外加可在每個表達式后寫一個換行符。
語法如下:
document.writeln(exp1,exp2,exp3,...)
exp1表示要寫入的輸出流。它們將按順序被追加到文檔中。
示例如下:
<html> <head> <meta charset="utf-8"> <title>123</title> </head> <body> <p>注意write()方法不會在每個語句后面新增一行:</p> <pre> <script> document.write("Hello World!"); document.write("Have a nice day!"); </script> </pre> <p>注意writeln()方法在每個語句后面新增一行:</p> <pre> <script> document.writeln("Hello World!"); document.writeln("Have a nice day!"); </script> </pre> </body> </html>
輸出結(jié)果:
【