javascript - Bootstrap 4 How to use multiple jQuery versions on same page -


this question has answer here:

i working on website i'd use jquery 2.2.4 , jquery 3.1.1. want use version 2.2.4 owl carousel 2, need 3.1.1 in order make standard fixed navbar bootstrap 4 alpha work.

however, when both add following lines..

<script type="text/javascript" src="/js/jquery-2.2.4.min.js"></script> <script type="text/javascript" src="/js/jquery-3.1.1.min.js"></script>

.. menu works. owl-carousel 2 initializer:

  $('.owl-carousel').owlcarousel({         loop: true,         margin: 30,         nav: false,         responsiveclass: true,         responsive: {             0: {                 items: 1             },             600: {                 items: 2             },             1000: {                 items: 3,                 loop: false,                 dots: true             }         }     }) 

i have searched other topics , came across noconflict(); option don't know how implement this.

so, need v2.2.4 carousel , need v3.1.1 fixed navbar (without initializer). how make possible without encountering problems?

yes, it's possible due jquery's noconflict mode.

<!-- load jquery 2.2.4 --> <script type="text/javascript" src="jquery-2.2.4.min.js"></script> <script type="text/javascript"> var jquery_2_2_4 = $.noconflict(true); </script>  <!-- load jquery 3.1.1 --> <script type="text/javascript" src="jquery-3.1.1.min.js"></script> <script type="text/javascript"> var jquery_3_1_1 = $.noconflict(true); </script> 

then, instead of $('#selector').function();, have use

jquery_2_2_4('#selector').function(); or jquery_3_1_1('#selector').function();


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -