如何将我的JavaScript文件包含到HTML页面中? [英] How can I include my JavaScript file into an HTML page?
本文介绍了如何将我的JavaScript文件包含到HTML页面中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在django中植入我的JavaScript文件.我知道如何包含CSS文件.我这样做是这样的:
I need to inculde my JavaScript file in django. I know how to include CSS files. I'm doing it this way:
<link rel="stylesheet" href="{% static 'demo/style.css' %}"/>
如何包含我的JavaScript文件?
How can I include my JavaScript file?
推荐答案
有两种方法(内联脚本和外部脚本):
There are two ways to do this (inline scripts and external scripts):
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Test page</title>
</head>
<body>
Inline script (option 1):
<script>
// your js code here
</script>
External script (option 2):
<script src="your-code-file.js"></script>
</body>
</html>
您可能对此感兴趣:
<script src="your-code-file.js"></script>
这篇关于如何将我的JavaScript文件包含到HTML页面中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文