Search code examples
javascriptjquerycordovamobile-application

Problems with jQuery in a PhoneGap app


Can't seem to get it included. I was using this:

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

and then had this:

<script type="text/javascript">

function initialize(){

 $(document).ready(function() {
   $("a").click(function() {
     alert("Hello world!");
   });
 });

}

</script>

....

<body onload="initialize()">
<a href="">Link</a>
</body>

But when I click the link, nothing happens. I have no way of knowing whether jQuery is even including properly. I'm completely new to jQuery, so for all I know I'm making an obvious error here, but it's straight from the jQuery beginner guide, so I'd think it was close at least. Anyone?


Solution

  • You can just remove that function. It is useless.

    $(function(){
        $("a").click(function(){
            alert("Hello world!");
        });
    });
    

    PS: Your code in work: http://jsfiddle.net/DerekL/h4dmF/