[英]Separate javascript in to own .js file
You may see a JS below which is now commented which is now copied in all-set.js
without two <script>
lines. 您可能会在下面看到一个JS,该JS现在已注释,现在已复制到
all-set.js
没有两行<script>
行。
It was working when I was using the code in head, now it's not. 当我在脑海中使用代码时,它正在工作,但现在不是。
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="all-set.js" ></script>
<!--
<SCRIPT language="javascript" >
$(function(){
// add multiple select / deselect functionality
$("#selectall").click(function () {
$('.case').attr('checked', this.checked);
});
// if all checkbox are selected, check the selectall checkbox
// and viceversa
$(".case").click(function(){
if($(".case").length == $(".case:checked").length) {
$("#selectall").attr("checked", "checked");
} else {
$("#selectall").removeAttr("checked");
}
});
});
</SCRIPT>
-->
</head>
What is your directory structure? 您的目录结构是什么?
Where is the JS
and where is the HTML
file? JS
在哪里, HTML
文件在哪里?
Are they right besides each other in the same folder? 它们在同一文件夹中彼此相邻吗?
If yes, try changing src
of your script
tag like: 如果是,请尝试更改
script
标记的src
,例如:
<script type="text/javascript" src="./all-set.js" ></script>
Inside the JS file remove the script tags. 在JS文件中,删除脚本标签。 These don't have to be there:
这些不必在那里:
<SCRIPT language="javascript" >
</SCRIPT>
Also, as a general rule, always use lower-case tags in HTML. 同样,通常,在HTML中始终使用小写标签。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.