Home  >  Article  >  Web Front-end  >  What are the output methods in js?

What are the output methods in js?

王林
王林Original
2020-05-23 17:36:483320browse

What are the output methods in js?

The output methods in js are:

1. Use window.alert() to pop up a warning box.

2. Use the document.write() method to write the content into the HTML document.

3. Use innerHTML to write to HTML elements.

4. Use console.log() to write to the browser's console.

1. window.alert()

Display data by popping up a warning box.

Code example:

What are the output methods in js?

Output:

What are the output methods in js?

2. document.write( )

Write the content directly into html.

Code example:

What are the output methods in js?

Output:

What are the output methods in js?

3. innerHTML

We can access an HTML element from JavaScript, using the document.getElementById(id) method, and use innerHTML to get or insert the element content.

Code example:

What are the output methods in js?

Output:

What are the output methods in js?

4. console .log

Writes data to the browser's console.

Code example:

What are the output methods in js?

Output:

What are the output methods in js?

Recommended tutorial: js introductory tutorial

The above is the detailed content of What are the output methods in js?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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