I am using bootstrap into a WordPress theme and I have a conflict between jQuery in wp-include folder and my theme jQuery
this is my function jQuery that need bootstrap.min.js and jquery.js
jQuery(function($) {'use strict',
//#main-slider
$(function(){
$('#main-slider.carousel').carousel({
interval: 8000
});
});
});
how could I resolve this problem ?
You have to put jQuery into no-conflict mode to use it along with other JS libraries. For example:
var $j = jQuery.noConflict();
// $j is an alias to the jQuery function
$j(document).ready(function() {
// ...
});
Your code is messy and your redefining what the $
symbol means.
If you actually wish to redefine the jQuery $
you can use the .noConflict
method.
jQuery.noConflict();
Make sure your selector is also correct #main-slider.carousel
would select an element that looks like the following <div id="main-slider" class="carousel">
. The selector #main-slider
would achieve the same result.
I suggest you include some HTML in your question. Failing that the code below is my best attempt to answer.
Try the following:
'use strict';
jQuery.noConflict(); // If you wish to remove the jQuery '$'.
jQuery(function(){
jQuery('#main-slider').carousel({
interval: 8000
});
});
The easiest way for one script is:
(function($){
$(function()){
//yours code
});
}(jQuery));