Easy Tutorial
❮ Sel First Event Click ❯

jQuery jQuery.sub() Method

jQuery Miscellaneous Methods

Example

Add a method to the 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: 1.


Syntax


More Examples

Override Some jQuery Methods

Create a Plugin


jQuery Miscellaneous Methods

❮ Sel First Event Click ❯