JQuery版本冲突。自举视差

时间:2014-04-04 13:23:35

标签: jquery html twitter-bootstrap parallax.js

我想在一个文档中使用不同的jQuery。 On用于引导程序MEGAMENU(1.11.0),较旧用于paralax脚本。

我的代码如下:

<script src="js/vendor/jquery-1.11.0.min.js" type="text/javascript"></script>
<script type="text/javascript">
var jQuery_1_11_0 = $.noConflict(true);
 $(function() {
        window.prettyPrint && prettyPrint()
        $(document).on('click', '.yamm .dropdown-menu', function(e) {
          e.stopPropagation()
        })
      })
</script>


<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript">
var jQuery_1_6_4 = $.noConflict(true);
$('#nav').localScroll(800);

    $('#intro').parallax("50%", 0.1);
    $('#second').parallax("50%", 0.1);
    $('.bg').parallax("50%", 0.4);
    $('#third').parallax("50%", 0.3);
</script>

它出了什么问题?

1 个答案:

答案 0 :(得分:0)

包含您对jQuery的引用。

<script src="js/vendor/jquery-1.11.0.min.js" type="text/javascript"></script>


// Run Your Code in another script tag. 
<script type="text/javascript">

 $(function() {

      // This code makes no sense to me, what intent do you have here?
      // It's essentially not doing anything at all. 
      window.prettyPrint && prettyPrint();


    $(document).on('click', '.yamm .dropdown-menu', function(e) {
      e.stopPropagation();
      // What else are you trying to do here?
    });

    // Adding the calls to the plugin. 
    $('#nav').localScroll(800);
    $('#intro').parallax("50%", 0.1);
    $('#second').parallax("50%", 0.1);
    $('.bg').parallax("50%", 0.4);
    $('#third').parallax("50%", 0.3);

 });

</script>

我将调用移动到jQuery包装函数中的parallax插件。这应该工作正常。如果它没有检查以确保所有需要jQuery的东西都不需要或破坏更新的jQuery版本。

我希望这会对你有所帮助。