Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can achieve this by running your version of jQuery in <a href="http://docs.jquery.com/Using_jQuery_with_Other_Libraries" rel="noreferrer">no-conflict mode</a>. "No conflict" mode is the typical solution to get jQuery working on a page with other frameworks like <a href="http://www.prototypejs.org/" rel="noreferrer">prototype</a>, and can be also be used here as it essentially namespaces each version of jQuery which you load.</p> <pre><code>&lt;script src="jQuery1.3.js"&gt;&lt;/script&gt; &lt;script&gt; jq13 = jQuery.noConflict(true); &lt;/script&gt; &lt;!-- original author's jquery version --&gt; &lt;script src="jQuery1.2.3.js"&gt;&lt;/script&gt; </code></pre> <p>This change will mean that any of the jQuery stuff you want to use will need to be called using <code>jq13</code> rather than <code>$</code>, e.g.</p> <pre><code>jq13("#id").hide(); </code></pre> <p>It's not an ideal situation to have the two versions running on the same page, but if you've no alternative, then the above method should allow you to use two differing versions at once.</p> <blockquote> <p>Also out of curiosity, what if we were to use an additional control that needed to reference yet another version of jQuery?</p> </blockquote> <p>If you needed to add another version of jQuery, you could expand on the above:</p> <pre><code>&lt;script src="jQuery1.3.js"&gt;&lt;/script&gt; &lt;script&gt; jq13 = jQuery.noConflict(true); &lt;/script&gt; &lt;script src="jQuery1.3.1.js"&gt;&lt;/script&gt; &lt;script&gt; jq131 = jQuery.noConflict(true); &lt;/script&gt; &lt;!-- original author's jquery version --&gt; &lt;script src="jQuery1.2.3.js"&gt;&lt;/script&gt; </code></pre> <p>The variables <code>jq13</code> and <code>jq131</code> would each be used for the version-specific features you require. </p> <p>It's important that the <strong>jQuery used by the original developer is loaded last</strong> - the original developer likely wrote their code under the assumption that <code>$()</code> would be using their jQuery version. If you load another version after theirs, the <code>$</code> will be "grabbed" by the last version you load, which would mean the original developer's code running on the latest library version, rendering the <code>noConflicts</code> somewhat redundant!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload