jQuery and prototype.js conflict, how to keep jQuery as $?

jquery, prototypejs

Solution

Instead of using document ready you can create a closure (at the end of the `body`) like:

(function($) {
  //jQuery stuff
  $('.elem') // $ refers to jQuery
})(jQuery);

If I understand your question correctly

Problem

So I'm working on a website that uses both jQuery and prototype.js, however their conflicting. I've researched a fair bit and found that the only way people fix this issue is by using ``` <script> jQuery.noConflict(); // Use jQuery via jQuery(...) jQuery(document).ready(function(){ jQuery(\"div\").hide(); }); // Use Prototype with $(...), etc. $('someid').hide(); ``` However I don't want to change $ to jQuery as that means I'd have to edit a fair bit of pre written code. Is there a way to stop them conflicting and leave jQuery as $?

Original source

Related problems