I am having issues with using jQuery.noConflict(true)
var jq = $.noConflict(true);
(function(jq) {
var jq = $;
console.log($);
})(_jQuery)
But i keep keep getting errors that its undefined. Is something able to help me pass a value to this function so I can use jQuery ?
Edit: I am trying to run a plugin inside an automatic executing function
(function($) {
console.log($);
(function($){
})(jQuery)
})(jq)
The problem is that the function constantly get undefined ?
I think perhaps you meant to do something like this which removes all jQuery globals, assigns the main jQuery global to your own variable
jq, then passes that to a self-executing function which takes an argument named$so you can then use$inside of the self executing function as the name for jQuery like this:If what you’re really trying to do is to load multiple versions of jQuery on the same page, you can read this post: Can I use multiple versions of jQuery on the same page?.
Here’s the principle in execution:
Then, to create an environment for your plugin, you can do this:
If this was my project, I’d spend some effort to figure out how to get all my code to use the same version of jQuery because multiple versions of jQuery slows down the loading of the page, consumes more memory and complicates the development and troublshooting. There is nothing good about it.