0

I'm trying to make a basic web application, but I cannot get my Javascript and JQuery to fire. If I try debugging, I can write JQuery commands in the console and they work fine, but no <script> tags are being executed (and nothing goes to the console either):

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width,user-scalable=no">
    <script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
</head>
    <body>
        <div class="ui-page ui-page-active" id="main">
            <div class="ui-content">
               <p id="changeme">foo</p>
            </div>
        </div>

        <script>
            console.log("ffs");
            $('#changeme').append("bar")
        </script>       
    </body>
</html>
Mr Lister
  • 45,515
  • 15
  • 108
  • 150

2 Answers2

0

I pasted your code into html file and it works in the emulator properly. The only problem was the letter is black and background is black too, and it positioned at out of circle screen(left-top outside). After I gave the styles like color: #ffffff; and text-align: center, the string become visible.

Natalie Hedström
  • 2,607
  • 3
  • 25
  • 36
0

Hello you should wait for the jquery object to be ready:

http://learn.jquery.com/using-jquery-core/document-ready/

"A page can't be manipulated safely until the document is "ready." jQuery detects this state of readiness for you."

Please try to replace

<script>
    console.log("ffs");
    $('#changeme').append("bar")
</script>

for

<script>
    console.log("ffs");
    $(document).ready(function(){
        $('#changeme').append("bar");
    });
</script>

I'm developing for wearable, so I found that, console.log is not the best way to debug.. insert an alert It should fire! Look for any error loading the JQuery script.

I was having this problem also this was what I did to solve it.

Cheers,

Ricardo

rmjoia
  • 962
  • 12
  • 21