【问题标题】:jquery functions inside of document.ready are not being called没有调用 document.ready 中的 jquery 函数
【发布时间】:2012-05-19 17:36:20
【问题描述】:

我是 jquery 的新手,看过一些教程,但我什至无法开始。看起来 $(document).ready 下的东西永远不会被调用。这是我的 HTML 的前几行:

<html>
<head>
<title>foobar</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script type=\"text/javascript\"> 
$(document).ready(function(){
   alert("READY!");
   $("*").click( function() {
       alert("CLICKED!");
   });
}); </script>
...(some other scripts)
</head>...

我觉得这是最基本的,但当我加载或单击页面中的某些内容时,我没有收到任何警报。从外部文件加载 jquery 也不起作用。我正在使用 Firefox 9。我不知道从哪里开始,而且我似乎无法在网上找到任何可以解决我问题的东西。有谁知道导致这种情况的原因可能是什么?谢谢!

【问题讨论】:

    标签: jquery document-ready


    【解决方案1】:

    您的脚本类型格式不正确。您可以通过删除反斜杠来修复它,但由于所有浏览器都默认使用 javascript,因此您可以完全省略它:

    <script type=\"text/javascript\">
    
    <script>
    

    【讨论】:

      【解决方案2】:

      &lt;script type=\"text/javascript\"&gt; 应该是 &lt;script type="text/javascript"&gt;。因为浏览器没有问题。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-12-10
        • 2017-03-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-05-25
        • 2018-06-18
        • 2017-12-27
        相关资源
        最近更新 更多