简体   繁体   English

在Chrome扩展程序弹出窗口中使用jQuery

[英]Using jquery in chrome extension popup

I am trying to setup a slider bar in the chrome extension popup. 我正在尝试在Chrome扩展程序弹出窗口中设置一个滑块。 My slider bar code requires jquery but unfortunately, my program will not recognize the jquery code in my popup js. 我的滑块条形码需要jquery,但是不幸的是,我的程序无法识别弹出式js中的jquery代码。 Here is the error produced when I inspect the popup: 这是我检查弹出窗口时产生的错误:

script.js:1 Uncaught TypeError: $(...).slider is not a function

Here is my script.js code that creates the slider bar. 这是创建滑动条的我的script.js代码。 Given that it does not execute past the first line, it seems that I have a jquery issue: 鉴于它没有执行到第一行,似乎出现了一个jquery问题:

$('.application-progress').slider({
range: "min",
min: 0,
max: 100,
animate: true,
slide: function(event, ui) {
    $("#progress").html(ui.value + "%");
    }
});

$("#progress").html($(".application-progress").slider("value") + "%");

$("input, select").change(function() {
    var percentage = 0;
    $('input, select').each(function() {
        if ($.trim(this.value) != "") percentage += 10;
    });
    $(".application-progress").slider("value", percentage);

    $("#progress").html(percentage + "%");
});

Here is the html code for my popup: 这是我的弹出窗口的html代码:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Slider Bar!</title>
        <script type="text/javascript" src="jquery-1.11.3.min.js"></script>
        <script type="text/javascript" src="script.js"></script>
    </head>
    <body>
        <div id="progress"></div><div class="application-progress"></div>
    </body>
</html>

Looks like you forgot to include jQuery UI: 看起来您忘记了包括jQuery UI:

<script type="text/javascript" src="jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="jquery-ui.min.js"></script>

Coz, jQuery UI Slider needs jQuery UI library to be loaded after jQuery. Coz, jQuery UI Slider需要在jQuery之后加载jQuery UI库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM