Skip to Content Skip to Menu

jQuery running with prototype

jQuery was nice enough to add in a function that helps with conflicting scripts. Typically prototype and jQuery use the $ sign to initialise their scripts. Code to help you achieve no conflicts:

//include your prototype
//include your jquery

//typical jQuery call
$("body").css("background", "red");

//now that jquery code can be run with conflict like this:
jQuery("body").css("background", "red");
//but prefixing with that every time not only adds more characters to the code, it just gets annoying

//so use the .noConflict function provided by jquery library
$j = jQuery.noConflict(); //assign a new variable to initialise jquery calls
$j("body").css("background", "red");

So after using the function supplied by jQuery, you shouldn't have problems running both at the same time. Good luck.