我无法运行我的javascript

时间:2015-02-23 04:29:52

标签: javascript jquery html5 twitter-bootstrap bower

这是我的代码的主要部分带来了我的Javascript和CSS库,但它不会运行我的jQuery文件

<link rel = "stylesheet" href = "bower_componets/bootstrap/dist/css/bootstrap.min.css">
<link rel = "stylesheet" href = "darkly.css">
<link rel = "stylesheet" href = "HistorySytleSheet.css"/>
<script type = "text/javascript" src = "bower_component/jquery/dist/jquery.min.js"></script>
<script type = "text/javascript" src = "bower_component/bootstrap/dist/js/bootstrap.min.js"></script>
<script type="text/javascript"  src = "HistoryJQ.js"></script>
那些问这个的人是我正在尝试运行的Jquery

var main = function () {
    $('arrow-next').click(function () {
        var currentSlide = $('active-slide');
        var nextSlide = currentSlide.next();

        var currentDot = $('active-dot');
        var nextDot = currentDot.next();

        if(nextSlide.length === 0)
        {
            nextSlide = $('.slide').first();
            nextDot = $('.dot').first();
        }   

        currentSlide.fadeOut(600).removeClass('active-slide');
        nextSlide.fadeIn(600).addClass('active-slide');

        currentDot.removeClass('active-dot');
        nextDot.addClass('active-dot'); 
    });


        $('.arrow-prev').click(function() {
    var currentSlide = $('.active-slide');
    var prevSlide = currentSlide.prev();

    var currentDot = $('.active-dot');
    var prevDot = currentDot.prev();

    if(prevSlide.length === 0) {
      prevSlide = $('.slide').last();
      prevDot = $('.dot').last();
    }

    currentSlide.fadeOut(600).removeClass('active-slide');
    prevSlide.fadeIn(600).addClass('active-slide');

    currentDot.removeClass('active-dot');
    prevDot.addClass('active-dot');
  });

};

$(document).readyState(main);

1 个答案:

答案 0 :(得分:2)

只是一个猜测:

你有:

<link rel = "stylesheet" href = "bower_componets/bootstrap/dist/css/bootstrap.min.css">

然后你有:

<script type = "text/javascript" src = "bower_component/jquery/dist/jquery.min.js"></script>
<script type = "text/javascript" src = "bower_component/bootstrap/dist/js/bootstrap.min.js"></script>

猜测您错误输入了bower_componetsbower_component,两者都应该是:bower_components
这意味着你可能没有加载jquery和bootstrap。

尝试一下:

<link rel = "stylesheet" href = "bower_components/bootstrap/dist/css/bootstrap.min.css">

<script type = "text/javascript" src = "bower_components/jquery/dist/jquery.min.js"></script>
<script type = "text/javascript" src = "bower_components/bootstrap/dist/js/bootstrap.min.js"></script>