3 ms·
Back in the first era of the JavaScript library was this was one of the big differences between Prototype and jQuery. Prototype added a whole bunch of new meth
by simonw 5y ago
Back in the first era of the JavaScript library was this was one of the big differences between Prototype and jQuery.
Prototype added a whole bunch of new methods to the built-in JavaScript objects. It also defined $ as an alias for document.getElementById.
jQuery added nothing to the built-in objects, but did also use $ as an alias for the jQuery function.
Something I really liked about jQuery was that it included a noConflict() function, which you could use to avoid it interfering with Prototype. Doing this:
jQuery.noConflict();
Reset the $ back to whatever it was before jQuery was loaded.
If you wanted to keep using $ in your jQuery code you could use this elegant idiom, which registers your code to run when the page content has loaded:
jQuery(function($) {
// Within this block $ is an alias of jQuery
});