【问题标题】:Simple jQuery not running简单的 jQuery 没有运行
【发布时间】:2014-08-31 01:17:15
【问题描述】:

这个简单的 jQuery 代码没有运行。 使用 Chrome,启用 Javascript。

<html>

<body>
    <h1>Click for info</h1>
    <p>Here is the extra information!</p>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

    <script type="text/javascript">
        $(document).ready({

            $("p").hide();

            $("h1").click(function(){
                $(this).next().slideToggle(300);
            });
        });
    </script>

</body>

感谢您提供的任何帮助:)

【问题讨论】:

  • Works jsfiddle.net/e4RvB your ready 缺少函数()
  • 没有运行?你怎么知道?你能提供一个jsfiddle吗?

标签: javascript jquery html google-chrome web


【解决方案1】:

$(document).ready({ 应该是$(document).ready(function() {

$(document).ready(function() {

    $("p").hide();

    $("h1").click(function(){
        $(this).next().slideToggle(300);
    });
});

【讨论】:

    猜你喜欢
    • 2014-12-02
    • 2015-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-01
    • 1970-01-01
    • 2011-08-30
    相关资源
    最近更新 更多