Using the $ alias in the plugin
In this example, let's modify the function defined in the plugin in the previous recipe to use the $
alias instead of the full jQuery
name. The use of the $
shortcut enhances the readability of the code, but its availability is not always guaranteed. It is possible that other libraries in a project also use $
. The use of the $.noConflict()
method releases the control of $
by jQuery to other libraries.
The constructs used in this example are summarized as follows:
Construct |
Type |
Description |
---|---|---|
|
jQuery function |
This refers to the jQuery function. |
|
jQuery selector |
This selects all elements with the specified HTML tag. |
|
jQuery method |
This inserts content at the end of each matched element. |
|
jQuery function |
This refers to the jQuery function. |
Getting ready
Let's see the requirements for using the $ alias in the jQuery plugin:
We will reuse the web form (
Sample.aspx
) and the plugin (jquery.sample...