What are the output methods in js?

王林
Release: 2020-05-23 17:36:48
Original
3265 people have browsed it

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!

Related labels:
js
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!