Search code examples
javascriptjqueryfirefox-os

Jquery is not working in firefox os simulator


I am just trying to add some Jquery in my app. But my jquery code is not working in the firefox os simulator. It working fine in my desktop browser. Please have a look at the image I have attached. What is the wrong?

enter image description here

And this is the code I am using

    <!DOCTYPE html>
<html>
<head>
<script src="js/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $("p").toggle();
    });
});
</script>
</head>
<body>

<button>Toggle</button>

<p>This is a paragraph with little content.</p>


</body>
</html>

Solution

  • For security reasons you can't use inline javascript in FirefoxOS apps. You need to place your JS in its own JS file and include it.

    Please see the beginners app for reference code: https://github.com/mdn/battery-quickstart-starter-template/blob/master/index.html