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

How to use JavaScript to access HTML elements

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

Share

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

Today, I would like to share with you how to use JavaScript to access HTML elements of the relevant knowledge, detailed content, clear logic, I believe that most people are too aware of this knowledge, so share this article for your reference, I hope you have something to gain after reading this article, let's take a look at it.

Load JavaScript in HTML

Use concise syntax to load external script files (the type attribute is not required):

Access HTML elements using JavaScript

A poor HTML format can cause JavaScript execution errors.

The following two JavaScript statements output different results:

Example

Varobj=getElementById ("Demo")

Varobj=getElementById ("demo")

Use lowercase file names

Most Web servers (Apache,Unix) are case-sensitive: london.jpg cannot be accessed through London.jpg.

Other Web servers (Microsoft,IIS) are case-insensitive: london.jpg can be accessed through London.jpg or london.jpg.

You must maintain a uniform style, and we recommend using lowercase file names.

File extension

The HTML file suffix can be .html (or .htm).

The CSS file suffix is .css.

The JavaScript file suffix is .js.

The difference between .htm and .html

There is essentially no difference between the extension files of .htm and .html. Both browsers and Web servers treat them as HTML files.

The difference is:

.htm was used in early DOS systems, which may now be limited to three characters.

There are no special restrictions on suffixes in Unix systems, and .html is generally used.

Technical difference

If a URL does not specify a file name (for example, the http://www.runoob.com/css/), server will return the default file name. The default file names are usually index.html,index.htm,default.html, and default.htm.

If the server is configured with only "index.html" as the default file, you must name the file "index.html" instead of "index.htm".

However, usually the server can set multiple default files, and you can set the default file name as needed.

Anyway, the full suffix of HTML is ".html".

That's all of the article "how to use JavaScript to access HTML elements". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

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