Abdel Rhman Mohmed
Abdel Rhman Mohmed

Reputation: 3

Jquery don't run in cordova app

I am working on cordova appache app on VS2015 . I want to use jquery in my app as I use it in web app . I tried to make it but it dosen't work . here is my code :

<!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>

Please advise .

Upvotes: 0

Views: 132

Answers (1)

Ian Grainger
Ian Grainger

Reputation: 5516

There's no jQuery script linked there. Surely you need to add:

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

(Or a link to the jquery file on your server)

To your script links - probably before index.js.

EDIT: Also your script tag is outside your HTML. Move it to the bottom of the body tag, instead:

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

Upvotes: 2

Related Questions