There are several printing methods in javascript

王林
Release: 2023-01-07 11:42:55
Original
17331 people have browsed it

There are three printing methods in JavaScript, namely window.alert(), document.write() and console.log().

There are several printing methods in javascript

#The operating environment of this article: windows10 system, javascript 1.8.5, thinkpad t480 computer.

In JavaScript, we usually use the following three ways to print data:

  • Use window.alert() to write the warning box

  • Use document.write() to write HTML output

  • Use console.log() to write to browser console

Let’s take a look at how they are used.

Using window.alert()

You can use an alert box to display data:

Example

   

我的第一张网页

我的第一个段落

Copy after login

Use document.write()

For testing purposes, it is more convenient to use document.write():

Example

   

我的第一张网页

我的第一个段落

Copy after login

Use console.log()

In the browser, you can Use the console.log() method to display data.

Please activate the browser console via F12 and select "Console" in the menu.

Example

   

我的第一张网页

我的第一个段落

Copy after login

Related video tutorial sharing:javascript video tutorial

The above is the detailed content of There are several printing methods 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!