Quantcast
Viewing all articles
Browse latest Browse all 14

Using JQuery & Prototype together

You would surely have used JQuery and Prototype for dynamic web applications like Lightview, Prototip, etc. Here i would show you how to user them two together, on the same page.

Problem
The Problem JQuery uses a “$” as a shortcut for “jQuery” and Prototype uses “$” as well. We can’t have JQuery and Prototype using the same “$” namespace.

The Fix
Thankfully JQuery has a neat little function called jQuery.noConflict( ) which you basically just need to stick at the top of your JQuery file and replace the “$” alias with “jQuery” for each function. Example:

jQuery.noConflict();
// Do something with jQuery
jQuery(“div p”).hide();
// Do something with another library’s $()
$(“content”).style.display = ‘none';

Of course, there are other ways of solving this issue with jQuery.noConflict( )

NOTE: JQuery doesn’t get along with MooTools and YUI very well either, luckily this can also be solved with the jQuery.noConflict( ) trick.

Image may be NSFW.
Clik here to view.

Image may be NSFW.
Clik here to view.
Share


Viewing all articles
Browse latest Browse all 14

Trending Articles