为什么不是这个非常简单的jQuery工作?

问题描述:

我是想通过一个页面的宽度作为变量背后asp.net C#code,并且只有在收到空字符串。我缩小到了jQuery函数根本就没有发射的问题。我把它改成了简单的code我可以来测试函数做什么:

I was trying to pass the width of a page as a variable to C# code behind asp.net, and was only receiving empty strings. I narrowed down to the problem that the JQuery function is simply not firing. I changed it to the simplest code I could just to test if the function was doing anything:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
    $(document).ready(function() 
    {
           alert("hello");
    });
</script>

然而,它仍然什么都不做。

And yet, it still does nothing.


  1. 我已经包含JQuery的

  2. 我三重检查我的语法

  3. 没有错误报道在控制台

  4. 我通过其他类似SO捂脸提问看了看,但没有他们的解决方案的工作(见上文)

什么令人难以置信的显而易见的事情我缺少什么?

What incredibly obvious thing am I missing?

您不能同时设置 [来源] 属性,包括对&LT;脚本方式&gt; 元素

You can't simultaneously set the [src] attribute and include contents for the <script> element.

如果你需要两个脚本,你需要使用两个独立的&LT;脚本方式&gt; 元素

If you need two scripts, you need to use two separate <script> elements.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
    jQuery(function($) {
        alert("hello");
    });
</script>

由于按照 HTML5规格上的&LT;脚本&GT; 元素

如果没有的src 属性,取决于价值的键入属性,但必须剧本的内容相匹配限制。结果
  如果有一个的src 属性,该元素必须为空或包含也符合剧本内容的限制仅脚本文件。

If there is no src attribute, depends on the value of the type attribute, but must match script content restrictions.
If there is a src attribute, the element must be either empty or contain only script documentation that also matches script content restrictions.