First JavaScript program code

Source: Internet
Author: User

<! DOCTYPE html>

The browser appears as follows:


Note that the JavaScript code is written here:


<script type="text/javascript">Indicates that the text type is between <script></script>, JavaScript is meant to tell the browser that the text is in the JavaScript language.

Can javascript code be written only in HTML files? Of course not, we can separate the HTML file and JS code, and create a separate JavaScript file (JS file), its file suffix is usually. js, and then the JS code directly in the JS file.

Note: In the JS file, you do not need to <script> tags, directly write JavaScript code on it.

JS file can not be run directly, embedded in the HTML file to execute, we need to add the following code in HTML, the JS file can be embedded in the HTML file.




First JavaScript program code

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.