Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of JavaScript statement, JavaScript Code and Code Block

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail the sample analysis of JavaScript statements, JavaScript code and code blocks. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

JavaScript statement

The command issued to the browser by the JavaScript statement. Statement is used to tell the browser what to do.

The following JavaScript statement outputs the text "Hello World" to the HTML element of id= "demo":

Document.getElementById ("demo") [xss_clean] = "Hello World"

semicolon

Semicolons are used to separate JavaScript statements. Usually we add a semicolon at the end of each executable statement.

Another use of semicolons is to write multiple statements in one line.

You may also see cases without semicolons. In JavaScript, it is optional to end statements with semicolons.

JavaScript code

The JavaScript code (or only JavaScript) is a sequence of JavaScript statements.

The browser executes each statement in the order in which it is written. The following example manipulates two HTML elements:

My Web PageA Paragraph.

A DIV. Document.getElementById ("demo") [xss_clean] = "Hello World"; document.getElementById ("myDIV") [xss_clean] = "How are you?"

JavaScript code block

JavaScript statements are combined in the form of code blocks. The block starts with the left curly bracket and ends with the right curly bracket.

The purpose of the block is to make the sequence of statements execute together. The JavaScript function is a typical example of combining statements into blocks.

The following example runs a function that manipulates two HTML elements:

My Web PageI am a paragraph.

I am a div.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report