JavaScript basic syntax 04 - input and output syntax

Hi everyone, I am Lei Gong.
Today I will learn the basic syntax of JavaScript, input and output syntax, and the following are study notes.

1. Output syntax:

1.1. Alert()
function: The interface pops up a warning dialog box.

Example:

    <script>
        alert(‘要输出的内容’)</script>

Note:
When JavaScript outputs a message, in order to ensure that the program can execute normally, it is recommended that all information be enclosed in quotation marks. Both single and double quotation marks are acceptable.

1.2. Document.write()
function: Output content into the body tag of the web page.

Example:

    <script>
            document.write(‘要输出的内容’)</script>

Insert image description here

**Note:** If the output content is written in tags, it will also be parsed into web page elements.

1.3. Function of console.log()
: Console output syntax, used by programmers when debugging.

Example:

    <script>
            console.log(‘要输出的内容’)</script>

2. Input syntax:

2.1. promt()
syntax: promt('Please enter your gender:')
Function: Display a dialog box that contains a prompt message to prompt the user to enter information
and display:
Insert image description here

2.2. Confirm()
function: select input.
Example:

    <script>
            confirm(“确定要关注雷工笔记吗?”)
    </script>

Show results:
Insert image description here

3. JavaScript code execution sequence

3.1. Execute JavaScript code in the order of the HTML document.
3.2. When alert() and prompt() are executed, they will skip the interface rendering and be executed first.

4. JavaScript syntax considerations

4.1. JavaScript strictly distinguishes between uppercase and lowercase letters.
4.2. If you want to output an HTML tag in the web page, you can use document.write()

5. Postscript

The above are study notes on basic JavaScript syntax and input and output syntax. Please correct me if there are any errors.
As the saying goes: Life lies in tossing, life is endless, tossing will not stop. Of course, don't mess around, but work hard to make life and the world better.

Guess you like

Origin blog.csdn.net/u013097500/article/details/132639067