[英]Javascript Runtime error: $ is undefined
I have added script in my Default.aspx page. 我在Default.aspx页面中添加了脚本。 I am getting following error.
我收到了以下错误。
$
is defined by jQuery, which you probably haven't referenced. $
由jQuery定义,您可能没有引用它。 A simple way to get it is to add one of the CDN urls to your template HTML: 获取它的一种简单方法是将一个CDN网址添加到模板HTML中:
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
You need to include jQuery: http://learn.jquery.com/about-jquery/how-jquery-works/ 你需要包含jQuery: http : //learn.jquery.com/about-jquery/how-jquery-works/
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Demo</title>
**<script src="jquery.js"></script>**
</head>
<body>
...
</body>
</html>
I had the same problem, but did have a correct reference to jQuery. 我有同样的问题,但确实有一个正确的jQuery引用。
I solved it by referencing jQuery before any other scripts. 我通过在任何其他脚本之前引用jQuery来解决它。 In your case, it would look like this:
在你的情况下,它看起来像这样:
<script src= "scripts/jquery-ui.js" />
<script src= "scripts/JavaScript_scroll.js" />
Hope this helps anyone else with a similar issue. 希望这有助于其他任何有类似问题的人。
I had the Same Problem as that $ is Unidentified, After a long struggle, I come to know that there is some thing HTML coder error in Master Page, So it worked fine when i include the Jquery files directly in Content page
我有同样的问题,因为$是未识别的,经过长时间的斗争,我才知道母版页中有一些HTML编码器错误,
So it worked fine when i include the Jquery files directly in Content page
(For others who may face the same problem as OP's) (对于可能遇到与OP相同问题的其他人)
I had the same problem, but the reason was that I was trying to load my jQuery
script before loading the jQuery
library itself. 我有同样的问题,但原因是我在加载
jQuery
库本身之前尝试加载我的jQuery
脚本。 In other words, make sure that you first add this line: 换句话说,请确保首先添加此行:
<script src="Scripts/jquery-{version}.min.js"></script>
before adding 在添加之前
<script src="Scripts/JavaSript_scroll.js"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.