jQuery jQuery.sub() Method
Example
Add a method to jQuery sub so that it is not exposed externally.
(function(){
var sub = jQuery.sub();
sub.fn.myCustomMethod = function(){
return 'just for me';
};
sub(document).ready(function(){
alert(sub('body').myCustomMethod());
});
alert(typeof jQuery('body').myCustomMethod); //undefined
})();
Definition and Usage
The $.sub() function creates a new copy of jQuery whose properties and methods can be modified without affecting the original jQuery object.
Note:
- Deprecated since jQuery 1.7, and will be moved to a plugin in jQuery 1.8.
$.sub()does not attempt any form of isolation. All methods in the jQuery copies still point to the original jQuery. (For example, event binding and triggering still happen through the original jQuery, data is bound to elements through the original jQuery, Ajax requests and events are run through the original jQuery, etc.)
Syntax
Note: This method does not accept any arguments.
_$_.sub()
More Examples
Override some jQuery methods to provide new functionality.
Create a plugin that returns specific methods of the plugin.
YouTip