""/> "">

Home  >  Article  >  Web Front-end  >  How to add js to html

How to add js to html

青灯夜游
青灯夜游Original
2021-05-14 16:37:5717310browse

Method: 1. Embed JavaScript code in the script tag of the html page; 2. Write the js code in a ".js" file, and then introduce the external js file through the src attribute of the script tag, syntax "6fe72667dc91a8b20b2098e5c999b5c02cacc6d41bbb37262a98f745aa00fbf0"

How to add js to html

The operating environment of this tutorial: windows7 system, javascript1.8.5&&HTML5 version , Dell G3 computer.

1. Embed JavaScript code in the script tag of the html page

Example:


    

2. Through the src attribute of the script tag Introducing external js files


    
    
    
    

In this way, the server will send the JavaScript file to the browser with the MIME type application/x-javascript.

Note:

Although the 3f1c4e4b6b16bbbd69b2ee476dc4f83a tag has many other attributes, these attributes are not commonly used, or they all have default values, and these default values ​​usually do not need to be changed, so The src attribute is probably the only attribute you need to know about.

Recommended tutorial: "html video tutorial"

The above is the detailed content of How to add js to html. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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