user2032610
user2032610

Reputation:

Creating copy of jQuery

Which is proper way creating a copy from jQuery?

var copyjq = new jQuery;

var copyjq or what?

Upvotes: 1

Views: 55

Answers (1)

Guffa
Guffa

Reputation: 700562

Use the sub method to create a copy of jQuery:

var copyjq= jQuery.sub();

Note: For version 1.9 and later the method was moved to a plugin.

If you just want another name for jQuery, and not a separate copy, you can just copy the reference:

var copyjq = jQuery;

You can also isolate the name inside a function expression:

(function(copyjq){
  ...
}(jQuery));

Upvotes: 3

Related Questions