if i have

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js" type="text/javascript"></script>

both of these in my header my jquery menu does not work. i have searched google and it keeps telling me about this

<script>
     jQuery.noConflict();
     
     // Use jQuery via jQuery(...)
     jQuery(document).ready(function(){
       jQuery("div").hide();
     });
     
     // Use Prototype with $(...), etc.
     $('someid').hide();
   </script>

for the life of me i cant work this out. can anybody explain this in layman terms. i beleive it is because they use the char set but i just dont understand how i can use them both together

many thanks

kard

Basically there is a conflict because both jQuery and prototype use "$" as their control character. To make jQuery work with other frameworks you should use

jQuery.noConflict();

To force jQuery to release the "$" and so you can either assign a new variable or just use jQuery (which is simpler). For more detailed info check out this link: http://docs.jquery.com/Using_jQuery_with_Other_Libraries The example from that article is here:

<html>
 <head>
   <script src="prototype.js"></script>
   <script src="jquery.js"></script>
   <script>
     jQuery.noConflict();
     
     // Use jQuery via jQuery(...)
     jQuery(document).ready(function(){
       jQuery("div").hide();
     });
     
     // Use Prototype with $(...), etc.
     $('someid').hide();
   </script>
 </head>
 <body></body>
 </html>

So anywhere you want to use a prototype function you reference with $ and anywhere you want to do jQuery you use the word jQuery.

Thanks for your reply. So do i change all the js files with JQuery instead of $ 99% of them i have just taken from the net and have not written as i am hopeless as js.

kardklub

Is there something specific that you are using prototype for? Chances are there is a jQuery plugin that will do the same and then your problem would be solved. Not certain what to do about external jQuery beyond that as I just recently ran across this noConflict solution on a forum recently (I generally just use stright JS or js with a bit of jQuery).

your probably right. its a validation form but ill look for a jquery validation. seems like to much hard work ;)

kard

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.