Not sure how to use jQuery noconflict function

I have been working on this site for the past two weeks, and so far everything has been working smoothly. I have conflicting javascripts and that's it, although I know which method to use to solve the problem (jquery noconflict), I have no idea how to use it!

In my case, I have:

  • drag and drop menu that uses js prototype and custom js
  • and a contact form that uses multiple jquery files to validate and report errors

The case is classic, they work fine, but not together. I read a gang of websites, and most of them point to a solution:

<script>

  jQuery.noConflict();

  // Use jQuery via jQuery(...)
  jQuery(document).ready(function(){
    jQuery("div").hide();
  });

  // Use Prototype with $(...), etc.
  $('someid').hide();

</script>

I am new to javascript, so I don't know what to do with this snippet.

This is my headline:

    <script src="js/prototype.js"></script>
    <script src="js/drop-o-matic.js"></script>
    <script>

  jQuery.noConflict();

  // Use jQuery via jQuery(...)
  jQuery(document).ready(function(){
    jQuery("div").hide();
  });

  // Use Prototype with $(...), etc.
  $('someid').hide();

    </script> 

    <!--[if lt IE 9]>

 <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
 <![endif]-->

    <!-- <script src="http://code.jquery.com/jquery-latest.js"></script>
 <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js"></script>
 <script src="js/jquery.jigowatt.js"></script> -->


    <script>
    document.createElement("article");  
    document.createElement("footer");  
    document.createElement("header");  
    document.createElement("hgroup");  
    document.createElement("nav");
    document.createElement("aside");
    document.createElement("section");
    document.createElement("menu");
    document.createElement("hgroup");
 </script> 

drop-o-matic js, js ( IE).

drop-o-matic html5 nav ( ,

        <nav>
            <ul>
                <li><a href="index.php" class="home">Home</a></li>
                ...
                ...
                ...
            </ul>
        </nav>

, ?

.

+5
2

, jQuery.noConflict(), jQuery! . jQuery script noConflict...

<script src="js/prototype.js"></script>
<script src="js/drop-o-matic.js"></script>
<script src="http://code.jquery.com/jquery-latest.js"></script><!-- IMPORTANT -->
<script>
  jQuery.noConflict();
</script>

jQuery , ...

var $j = jQuery.noConflict();

$j(document).ready(function() {
  $j("div").hide();
});

API jQuery

+9

, jQuery:

$jq = jQuery.noConflict();

, $ jQuery,

$jq("document").ready(function(){

// rest of your jQuery code inside;

});
0

All Articles