OWL Carousel jQuery代码没有按预期工作

时间:2015-10-11 17:43:47

标签: javascript jquery html

我是jQuery的新用户。我在html代码中遇到了这个问题。代码为灰色,无法在网站中使用。有人能帮帮我吗?这是代码段。

$(document).ready(function() {

    $(".our-team").owlCarousel({
        items : 4,
        itemsDesktopSmall : [970, 4],
        theme:"team-slider-theme",
    });

});
<div class="our-team"> 
                    <div class="single-member">
                        <img src="img/member-face.png" alt="">
                        <h3>Jason Statham<span>Knife designer </span></h3>
                        <p>Do not seek to change what has come before. Seek to create that which has not.</p>
                    </div>
                    <div class="single-member">
                        <img src="img/member-face.png" alt="">
                        <h3>Jason Statham<span>Knife designer </span></h3>
                        <p>Do not seek to change what has come before. Seek to create that which has not.</p>
                    </div> 
                    <div class="single-member">
                        <img src="img/member-face.png" alt="">
                        <h3>Jason Statham<span>Knife designer </span></h3>
                        <p>Do not seek to change what has come before. Seek to create that which has not.</p>
                    </div>   
                    <div class="single-member">
                        <img src="img/member-face.png" alt="">
                        <h3>Jason Statham<span>Knife designer </span></h3>
                        <p>Do not seek to change what has come before. Seek to create that which has not.</p>
                    </div>
                    
                </div>

1 个答案:

答案 0 :(得分:0)

查看其工作http://jsfiddle.net/vnpm1y06/50/。我刚刚测试了你的代码,你没有正确地包含所有内容。

HTML

<div class="our-team"> 
    <div class="single-member item">
        <img  src="img/member-face.png" alt="">
        <h3>Jason Statham<span>Knife designer </span></h3>
        <p>Do not seek to change what has come before. Seek to create that which has not.</p>
    </div>
    <div class="single-member item">
        <img src="img/member-face.png" alt="">
        <h3>Jason Statham<span>Knife designer </span></h3>
        <p>Do not seek to change what has come before. Seek to create that which has not.</p>
    </div> 
    <div class="single-member item">
        <img src="img/member-face.png" alt="">
        <h3>Jason Statham<span>Knife designer </span></h3>
        <p>Do not seek to change what has come before. Seek to create that which has not.</p>
    </div>   
    <div class="single-member item">
        <img src="img/member-face.png" alt="">
        <h3>Jason Statham<span>Knife designer </span></h3>
        <p>Do not seek to change what has come before. Seek to create that which has not.</p>
    </div>

</div>

JS

$(document).ready(function() {

$(".our-team").owlCarousel({
    items : 1,
    itemsDesktopSmall : [970, 4],
    theme:"team-slider-theme",
});

});

修改

在你的主要风格包括

之前
<link rel="stylesheet" href="css/owl.carousel.min.css">
<link rel="stylesheet" href="css/owl.theme.default.min.css">

页脚包含

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> 
<script src="js/owl.carousel.min.js"></script>
<script src="js/yourMainJsFileWhereYourJsCodeIs.js"></script>