试图让pureSlider与jQuery一起使用

时间:2016-07-13 20:20:20

标签: jquery

我正在使用pureSlider,我有一个引导导航栏,需要jquery折叠并切换较小设备/屏幕上的菜单。有没有办法让pureSlider和jquery元素在我的页面上工作?

这是我的代码

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title></title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="styles.css" rel="stylesheet">
    <link href='https://fonts.googleapis.com/css?family=Vollkorn' rel='stylesheet' type='text/css'>
    <script type="text/javascript" src="assets/js/jbone.js"></script>
    <script type="text/javascript" src="pureSlider.js"></script>


    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

      <style>

          html {
                height: 100%;
                background-color: #4be1f0;
          }


          body {
                font-family: 'Vollkorn', sans-serif;
                position: relative;
                background-color: #4be1f0;

          }

          #container {
              width: 1200px;
              height: auto;
              margin: 100px auto;
          }


      </style>
  </head>

    <body>

        <nav role="navigation" class="navbar navbar-custom navbar-fixed-top" id="mynavBar">
            <div class="container-fluid">
                <div class="navbar-header">
                    <a class="navbar-brand"></a>
                    <button type="button" class="navbar-toggle" data-target="#navbarCollapse" data-toggle="collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    </button>
                </div>

                <div class="navbar-collapse collapse" id="navbarCollapse">
                    <ul class="nav navbar-nav navbar-right">
                        <li class="active"><a href="#">Home</a></li>
                        <li><a href="#a">About</a></li>
                        <li><a href="#promise">Contact</a></li>
                    </ul>
                </div>
            </div>
        </nav>

        <div id="container">
            <div id="banner2">
                <div class="stage">
                    <div class="slide" style="background-image: url('images/banner.jpg')"><span/>RESPONSIVE</span></div>
                    <div class="slide" style="background-image: url('assets/img/img2.jpg')"><span/>PERSONALIZED</span></div>
                    <div class="slide" style="background-image: url('assets/img/img3.jpg')"><span/>PROFESSIONAL</span></div>
                    <div class="slide" style="background-image: url('assets/img/img4.jpg')"><span/>OPTIMIZED</span></div>
    <!--                <div class="slide" style="background-image: url('assets/img/poppies.jpg')"><span>Poppies on fifth slide</span></div>-->
                    <div class="next">&rtrif;</div>
                    <div class="prev">&ltrif;</div>
                </div>
            </div> 
        </div>







        <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<!--    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>-->
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"> </script>
    <script>
         $('.stage').pureSlider({ 
        slideNode: '.slide'
        });
    </script>


  </body>
</html>

1 个答案:

答案 0 :(得分:0)

我不确定你在这里要做什么,但看看代码:

  • 你没有严格要求jBone for pureSlider工作,实际上,用jQuery加载jBone会引起冲突。 pureSlider可以与任何与jQuery兼容的库一起使用,只要你在该库之后加载它。
  • 因为0.8.0 pureSlider不再依赖类似jQuery的库,所以加载它时无关紧要,除非你想以类似jQuery的方式使用它:$('collection').pureSlider();,in它需要在jQuery之后加载,所以它可以注册为它的插件。