A plugin piece of code written in a standard JavaScript file. These files provide useful jQuery methods that can be used and jQuery library methods.
We insert a plugin file that closely resembles a jQuery library file in the
document to make plugin methods available to us.We have to make sure it appears in the back of the main jQuery source file and front of our custom JavaScript code.
This is very easy to write your plugin. The following is a syntax for building a path -
Here methodNameM is the name of the new method, and method definition is the definition of the actual method.
In the end, any path or function you paste should be semicolon (;).
Your method should return a jQuery item unless the specification is otherwise specified.
You should use this.each to scale over the current set of compatible items - it produces clean and consistent code that way. 4.
Start the file name with jquery, follow that with the plugin's name, and end with .js. Always attach the plugin to jQuery directly instead of $, so users can use the custom alias in the noConflict () way.
For example, if we are writing a plugin that we want to remove as debugs, our JavaScript file name for this plugin is -
Use of jquery. Start eliminates any possible word conflicts with files for use with other libraries.
|