Home > Web Front-end > JS Tutorial > How to use write() in JavaScript

How to use write() in JavaScript

青灯夜游
Release: 2021-11-03 16:35:15
Original
5764 people have browsed it

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.

How to use write() in JavaScript

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

JavaScript write()

The write() method writes HTML expressions or JavaScript code to the document.

Syntax:

document.write(exp)
Copy after login
  • 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>
Copy after login

Rendering:

How to use write() in JavaScript

[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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template