【问题标题】:jquery not running in project HTML, CSS [closed]jquery没有在项目HTML,CSS中运行[关闭]
【发布时间】:2013-05-30 19:45:52
【问题描述】:

当我使用 aptana 运行我的项目时,网络浏览器向我显示 HTML + CSS,但我无法使用按钮进行迭代。该按钮上有一个 jquery 脚本:

$(document).ready(function(){
$('#button').click(function(){
    var toAdd = $('input[name=checkListItem]').val();
    $('.list').append('<div class="item">' + toAdd + '</div>');
});
});

<!DOCTYPE html>
<html>
    <head>
        <title>To Do</title>
        <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
        <script type="text/javascript" src="script.js"></script>
    </head>
    <body>
        <h2>To Do</h2>
        <form name="checkListForm">
            <input type="text" name="checkListItem"/>
        </form>
        <div id="button">Add!</div>
        <br/>
        <div class="list"></div>
    </body>
</html>

【问题讨论】:

  • 你在哪里包含 jQuery 库?
  • 它是working。您必须在项目中包含 JQuery。
  • 我应该在哪里包含库?在项目中直接作为 .js 文件?我已经添加了 jquery 包
  • @user2437957 如果您愿意,可以将其包含为 .js 文件,或从 Google 加载
  • 我是否需要像使用 script.js 文件一样引用我的 html 文件中的库? @天顶

标签: jquery html css aptana


【解决方案1】:

您需要包含 jQuery 库。

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>

【讨论】:

    猜你喜欢
    • 2012-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-16
    相关资源
    最近更新 更多