javascript 未捕获的引用错误:$ 未定义(匿名函数)$(function() 不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17158054/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uncaught Reference Error: $ is not defined (anonymous function) $(function() does not work
提问by user2495173
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<link rel="stylesheet" href="https://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script language="Javascript" type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script>
<script language="Javascript" type="text/javascript" src="https://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<style type="text/css">
.ui-datepicker { font-size: 62.5%; }
</style>
<script>
$(function() {
$("#StartDate").datepicker({ dateFormat: "yy-mm-dd" }).val();
$("#EndDate").datepicker({ dateFormat: "yy-mm-dd" }).val();
});
</script>
</head>
<body bgcolor='#6a7c99'>
<input id='StartDate' type='text' style='position:absolute;top:35px;left:92px;width:55px;font-family:arial narrow;font-size:8pt;display:none;' name='StartDate'>
<input id='EndDate' type='text' style='position:absolute;top:75px;left:92px;width:55px;font-family:arial narrow;font-size:8pt;display:none;' name='EndDate'>
</body>
</html>
This code does not work. $function() does not work and throws an error. Whats wrong? What other jQuery libraries should be included?
此代码不起作用。$function() 不起作用并引发错误。怎么了?应该包含哪些其他 jQuery 库?
回答by karthikr
Looks like the links for jqueryand jquery uiare throwing a 504. Hence the error.
https://
does not work.
看起来jquery和jquery ui的链接抛出了 504。因此出现错误。
https://
不起作用。
Try this:
试试这个:
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script language="Javascript" type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script language="Javascript" type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>