【问题标题】:Jquery is not working in firefox os simulatorJquery 在 firefox os 模拟器中不工作
【发布时间】:2015-11-26 17:36:05
【问题描述】:

我只是想在我的应用程序中添加一些 Jquery。但是我的 jquery 代码在 firefox os 模拟器中不起作用。它在我的桌面浏览器中运行良好。请看一下我附上的图片。怎么了?

这是我正在使用的代码

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

【问题讨论】:

    标签: javascript jquery firefox-os


    【解决方案1】:

    出于安全原因,您不能在 FirefoxOS 应用程序中使用内联 javascript。您需要将您的 JS 放在它自己的 JS 文件中并包含它。

    参考代码请看初学者应用:https://github.com/mdn/battery-quickstart-starter-template/blob/master/index.html

    【讨论】:

    • 谢谢。我明白。 :)
    【解决方案2】:

    使用https://jsfiddle.net/ 测试您的代码。

    这是工作代码。享受吧。

    <button class='button1'>Toggle</button>
    
    <p>This is a paragraph with little content.</p>
    
    
    $(document).ready(function(){
        $(".button1").click(function(){
            $("p").toggle();
        });
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-03-30
      • 2012-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多