[英]My external javascript JQUERY doesn't work on chrome or other browser
The html file is 该html文件是
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>My Website /title>
<link rel='stylesheet' type='text/css' href='stylesheet4.css'>
<link rel='stylesheet' type='text/css' href='http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css'>
</head>
<body>
<!--other code -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="script3.js"></script>
</body>
</html>
and my script3.js file is 我的script3.js文件是
$(function(){
"use strict";
$('#checkOut').click(function(){
var time=2;
alert("The time is "+time+"!");
// more code
});
how am I linking it wrong? 我如何将其链接错误? when i used jfiddle to test my code, the alert works when i click the button. 当我使用jfiddle测试我的代码时,单击该按钮时警报将起作用。 however, i'm using notepad++ and i'm not sure what I'm doing wrong. 但是,我正在使用记事本++,并且不确定自己在做什么错。
I see two issues, and something else you should fix. 我看到两个问题,还有一些应该解决的问题。
In the script3.js, you have a missing });
在script3.js中,您缺少});
;。 . 。 So it should be: 所以应该是:
$(function(){
"use strict";
$('#checkOut').click(function(){
var time=2;
alert("The time is "+time+"!");
// more code
});
});
The title tag is not formatted correctly: 标题标签的格式不正确:
<title>My Website /title>
Needs to be: 需要是:
<title>My Website </title>
EDIT: Example: 编辑:示例:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>My Website </title>
<link rel='stylesheet' type='text/css' href='stylesheet4.css'>
<link rel='stylesheet' type='text/css' href='http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css'>
</head>
<body>
<!--other code -->
<input type="button" id="checkOut" value="check out" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="script3.js"></script>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.