Writing jQuery plugins
There are a few simple rules to writing jQuery plugins which prevent issues later down the line.
1) start with an IIFE which passes through jQuery into its scope
(function($, window, undefined) {
// your plugin will go here
}(jQuery, window));
2) Define your plugin functions as an…