简体   繁体   中英

JQuery Cycle Plugin stops working when I include the jquery.js script neccessary for Bootstrap

I have been attempting to recreate the jQuery Cycle Plugin shown here . I am also using bootstrap 3. If I remove the line <script type="text/javascript" src="static/js/jquery.js"></script> then it works, however, I need this for my responsive nav-bar and really have no idea why it is doing this. Here is the source code: and the live page is here . I have been trying for several hours to get this and have just hit a brick wall.

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">



<!-- Bootstrap -->
<link rel="stylesheet" type="text/css" href="static/css/bootstrap.css" />
<link href="static/css/bootstrap-theme.css" rel="stylesheet">
<link href="static/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="static/css/bootstrap-theme.min.css" rel="stylesheet" media="screen">

<link rel="stylesheet" type="text/css" href="static/css/style.css"> 

<link rel="shortcut icon" href="./static/images/favicon.ico" type="image/x-icon">
<link rel="icon" href="./static/images/favicon.ico" type="image/x-icon"><title>JQuery Cycle Plugin - Basic Demo</title>
<style type="text/css">
.slideshow { height: 232px; width: 232px; margin: auto }
.slideshow img { padding: 15px; border: 1px solid #ccc; background-color: #eee; }
</style>
<!-- include jQuery library -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<!-- include Cycle plugin -->
<script type="text/javascript" src="http://malsup.github.com/jquery.cycle.all.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    $('.slideshow').cycle({
        fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
    });
});
</script>
</head>
<header class="navbar navbar-inverse navbar-fixed-top bs-docs-nav" role="banner">
    <div class="container">
        <div class="navbar-header">
            <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".bs-navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            </button>
            <a id="nav-home" href="./index.html" class="navbar-brand">Home</a>
        </div>
        <nav class="collapse navbar-collapse bs-navbar-collapse" role="navigation">
            <ul class="nav navbar-nav">

                <li id="nav-resume"><a id="link" href="resume.html">Resume</a></li>
                <li id="nav-projects"><a id="link" href="portfolio.php">Portfolio</a></li>
                <li id="nav-contact"><a id="link" href="contact.html">Contact Me</a></li>

            </ul>
        </nav>
    </div>
</header>
<div id="wrap">
<div class="container">
<!--container is ended in footer tag.--><body>
    <div class="slideshow">
        <img src="http://malsup.github.com/images/beach1.jpg" width="200" height="200" />
        <img src="http://malsup.github.com/images/beach2.jpg" width="200" height="200" />
        <img src="http://malsup.github.com/images/beach3.jpg" width="200" height="200" />
        <img src="http://malsup.github.com/images/beach4.jpg" width="200" height="200" />
        <img src="http://malsup.github.com/images/beach5.jpg" width="200" height="200" />
    </div>

    </div>
</div>
<!--
<div id="footer">
    <div class="container">
        <p1 class="text-muted credit">&copy; 2013 michaelwashburnjr.com</p1>
    </div>
</div>
-->

<!-- Includes -->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script type="text/javascript" src="static/js/jquery.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script type="text/javascript" src="static/js/bootstrap.min.js"></script>
</body>
</html>

[Edit] I am now using <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> instead of <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> and having the same error.

The jQuery file you are loading is old, Bootstrap requires a higher version looking at their bower package "jquery": ">= 1.9.0"

https://developers.google.com/speed/libraries/devguide#jquery

You are including jQuery twice in a way that is destroying the cycle plugin. You have:

<!-- include jQuery library --> // FIRST INCLUDE
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<!-- include Cycle plugin -->
<script type="text/javascript" src="http://malsup.github.com/jquery.cycle.all.js"></script>

...

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> // SECOND INCLUDE
<script type="text/javascript" src="static/js/jquery.js"></script>

You should move all of your scripts to the bottom, and include them thusly:

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script type="text/javascript" src="static/js/jquery.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script type="text/javascript" src="static/js/bootstrap.min.js"></script>

<!-- include Cycle plugin -->
<script type="text/javascript" src="http://malsup.github.com/jquery.cycle.all.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    $('.slideshow').cycle({
        fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
    });
});
</script>

That way your second copy of jQuery doesn't destroy the plugins which were registered with the first copy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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