Suppose i have different versions of jquery.min.js and other version .If i want to include both in html script tag,may be there is a conflict over those files which have to choose.So can we overcome that conflict
Asked
Active
Viewed 465 times
0
-
Why would you want to include both, that's the real question – Eric Aug 10 '15 at 13:39
-
@Eric sometimes you have to because plugins depend on specific versions. – dmeglio Aug 10 '15 at 13:40
-
If i have any usage of both the files of different versions.One version supports one thing another have advanced.So how to to use both – Naga Bhavani Aug 10 '15 at 13:41
-
2Take a look at http://stackoverflow.com/questions/1566595/can-i-use-multiple-versions-of-jquery-on-the-same-page – dmeglio Aug 10 '15 at 13:41
-
try using `jQuery.noConflict()` in this case. – Jai Aug 10 '15 at 13:41
1 Answers
0
Multiple versions of jQuery can be included by using noConflict. For instance, if you wanted to include the 1.x and 2.x versions on the same page, you could reference each by supplying an alias:
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script>var jq1x = jQuery.noConflict();</script>
<script>
// $ == jQuery 2.x
$('#foo').on('click',function(){
// binding using 2.x
});
</script>
<script>
(function($){
// $ == jQuery 1.x
$('#bar').on('click',function(){
// binding using 1.x
});
})(jq1x);
</script>
Brad Christie
- 100,477
- 16
- 156
- 200