Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery jQuery.sub() method

jQuery jQuery.sub() method

jQuery Miscellaneous MethodsjQuery Miscellaneous Methods

Example

Add a method to the jQuery sub copy 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

)

;

//

underfine

}

)

(

)

;

Try it »


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. Deprecated since jQuery 1.7; in jQuery 1.8 it was moved to a plugin.
2. $.sub() does not attempt any form of isolation. All methods in the jQuery copy still point to the original jQuery. (For example, event binding and triggering still go through the original jQuery, and data is bound to elements through the original jQuery. Ajax requests and events are also run through the original jQuery, and so on.)


Syntax

Tip:

This method accepts no arguments.

$

.sub()


More examples

Override some jQuery methods
Override some jQuery methods to provide new functionality.

Create a plugin
Create a plugin that returns the plugin's specific methods.


jQuery Miscellaneous MethodsjQuery Miscellaneous Methods