-1

In my code listed below, jQuery is version 1.9.1 and jQuery1 is version 1.2.6, how will I be able to integrate both of them so that both will be compatible with each other?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Auto Complete Input box</title>
        <link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" />
        <script type="text/javascript" src="js/jquery1.js"></script>
        <script type="text/javascript" src="js/jquery.js"></script>
        <script type="text/javascript" src="js/jquery.autocomplete.js"></script>
        <script>
            $(document).ready(function() {
                $("#tag").autocomplete("autoCompleteMain.php", {
                    selectFirst: true
                });
            });
        </script>
    </head>
    <body>
        <form>
            <label>Tag:</label>
            <input name="tag" type="text" id="tag" size="20" />
        </form>
    </body>
</html>
JJJ
  • 32,902
  • 20
  • 89
  • 102
  • 1
    Why do you want to do that? – Salman A Mar 31 '13 at 08:07
  • Sometimes, you are working with a legacy version in an existing site (e.g. Wordpress) but you want a new version of jquery for a specific feature. This way you can leave the existing site unchanged but still use a newer version. – SteveP Mar 31 '13 at 08:09

1 Answers1

1

You can't call jQuery more than once, that will cause errors. You can, however, assign jQuery to its own variable when you load it.

<script src="first/js/file.js"></script>
var $j = jQuery.noConflict();

Load second file..

From here on out you would use $j instead of the usual $

Use the first jQuery version...

$j('#someID').hide();

Use the second jQuery version:

$('#someID').show();
What have you tried
  • 11,018
  • 4
  • 31
  • 45