【问题标题】:Jquery don't run in cordova appJquery不在cordova应用程序中运行
【发布时间】:2016-01-06 16:57:05
【问题描述】:

我正在 VS2015 上开发 cordova appache 应用程序。我想在我的应用程序中使用 jquery,就像在 web 应用程序中使用它一样。我试图做到,但它不起作用。这是我的代码:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>test</title>
    <!-- test references -->
    <link href="css/index.css" rel="stylesheet" />
</head>
<body>
    <p>Hello, your application is ready!</p>
    <!-- Cordova reference, this is added to your app when it's built. -->
    <script src="cordova.js"></script>
    <script src="scripts/platformOverrides.js"></script>
    <script src="scripts/index.js"></script>
</body>
</html>
<script>
    $(document).ready(function () {
        alert("test!");
    });
</script>

请指教。

【问题讨论】:

    标签: javascript jquery html cordova


    【解决方案1】:

    那里没有链接 jQuery 脚本。当然你需要添加:

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js"></script>
    

    (或指向您服务器上的 jquery 文件的链接)

    到您的脚本链接 - 可能在 index.js 之前。

    编辑:您的脚本标签也在您的 HTML 之外。将它移到 body 标签的底部,而不是:

        <script>
          $(document).ready(function () {
            alert("test!");
          });
        </script>
      </body>
    </html>
    

    【讨论】:

    • 它对我不起作用。如果有帮助,我会使用 windows 10。谢谢
    猜你喜欢
    • 1970-01-01
    • 2023-04-11
    • 2018-02-15
    • 1970-01-01
    • 2016-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多