What are the JavaScript output methods?

coldplay.xixi
Release: 2020-11-30 13:46:12
Original
3233 people have browsed it

JavaScript output methods are: 1. alert output, add relevant code in the tag []; 2. [document.write] output, output directly on the page.

What are the JavaScript output methods?

The operating environment of this tutorial: windows10 system, javascript1.8.5, this article is applicable to all brands of computers.

Related free learning recommendations:JavaScript(video)

##JavaScript output methods are:

1. Alert output

This method is what we often see when browsing the web, that is, a prompt will pop up when we browse the web. This effect is output through alert mode. Let's use the tool to type the code to see its structure and see how it is written. Let's take a look at this picture.

The code is very simple. We only need to type a line of code like alert("Hello World"); in the tag. We can change the content inside the quotation marks, so that there will be different prompts in the browser.

What are the JavaScript output methods?

alert mode output

What are the JavaScript output methods?

alert mode output result

2. document. write output

This output method is directly output on the page. It's also very simple. Let's take a look at the code and running effects. We just need to type document.write("Hello World"); and that's it.

What are the JavaScript output methods?

document.write output

What are the JavaScript output methods?

Output effect

3, console.log Output

This method is used for debugging and is output through debugging tools. Its format is

console.log("Hello World");At this point we open the browser and run it to see the effect. Found that the page has nothing, do you know why? Because this way is viewed through debugging tools. We open the browser, press F12 or inspect the element and click console to display it. Look at the picture below.

What are the JavaScript output methods?

console mode output

What are the JavaScript output methods?

#Running effect

This is the output method of JavaScript, third As developers, this is something we often use, so we need to master it.

The above is the detailed content of What are the JavaScript output methods?. 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!