Home >Web Front-end >JS Tutorial >How to use write() in JavaScript
In JavaScript, the write() method is used to write HTML expressions or JavaScript code to the document, the syntax is "document.write(exp)"; the parameter "exp" can be one or more ", ” separated values, they will be appended to the document in order.
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
The write() method writes HTML expressions or JavaScript code to the document.
Syntax:
document.write(exp)
exp
: Optional, specify the output stream to be written; it can be one or more with "," Separated values (exp1,exp2,exp3,...expN
), they will be appended to the document in the order in which they appear.
Example:
<!DOCTYPE html> <html> <body> <script> document.write("Hello World!"); document.write("<h1>Hello World!</h1><p>Have a nice day!</p>"); </script> </body> </html>
Rendering:
[Recommended learning: javascript Advanced Tutorial】
The above is the detailed content of How to use write() in JavaScript. For more information, please follow other related articles on the PHP Chinese website!