Home > Web Front-end > HTML Tutorial > Teach you step by step how to introduce external JS files into HTML

Teach you step by step how to introduce external JS files into HTML

烟雨青岚
Release: 2020-07-02 11:56:36
forward
6671 people have browsed it

Teach you step by step how to introduce external JS files into HTML

When learning the front-end, friends must be confused about how to introduce external JS files into HTML. The following editor will teach you how to introduce external JS files into HTML.

When an external JS file is introduced, code cannot be inserted between <script></script>. The inserted code will not be executed, only the imported external file will be executed.

attack.html Code:

##

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>系好安全带,准备启航</title>
<!--引入外部文件的方式-->
<script type="text/javascript" src="attack.js"></script>
</head>
<body>
<form>
<input type="button" value="开始游戏" onclick="attackEnemy()"/>
</form>
</body>
</html>
Copy after login

attack.js Code

function attackEnemy() {
document.write("land on");
alert("ready go");
}
Copy after login

Thank you everyone for reading, I hope you will benefit a lot.

This article is reproduced from: https://blog.csdn.net/u012871987/article/details/72638373

Recommended tutorial: "

HTML Tutorial"

The above is the detailed content of Teach you step by step how to introduce external JS files into HTML. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template