JQuery only allows one version

I have a third-party script that includes jquery (which makes things break). I am using version 1.6, and the external script is using an older version.

How can I make download only one version of jquery, and this is the version that I have on the page, and not the one that is downloaded externally?

+3
source share
2 answers

This is fairly easy to do using jquery.noConfict ();

<script src='jquery-1.6.js'></script>
<script>
var jq16 = jQuery.noConflict();
</script>
<script src='jquery-1.4.2.js'></script>
<script>
var jq142 = jQuery.noConflict();
</script>

Then you can use the functions in the $ () namespace:

 (function($) {
$('<button>Use jQuery 1.4.2</button>')
    .click(function() {
        alert('Top: ' + $(this).offset().top + '\n' +
            'jQuery: ' + $.fn.jquery);
    })
    .appendTo('body');
})(jq142);

Below is a more detailed example and some additional tips on this page .

+5
source

USE . noConflict() ?
:
<head> HTML:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
<script type="text/javascript">
jQuery.noConflict()
jQuery16 = jQuery
</script>

jQ script :

jQuery16(document).ready(function($){


$('.textarea').text(' Hello World! ');



});

, , MY script , - / jQuery.

+1

All Articles