div {
margin-bottom: 15px;
font-family: verdana;
font-size: 10px;
}
JavaScript
/*!
* $.createPlugin(pluginName, pluginImplementation)
*
* jQuery Plugin Creation Method (boilerplate plugin implementations)
* This script defines a new jQuery method called "createPlugin",
* used to easily create new jQuery plugins within the "$.fn" plugin scope.
*
* This method returns nothing, and receives two required parameters:
* [string] pluginName: the unique plugin name.
* [object] pluginImpl: the object containing the plugin implementation.
*
* The method tries to easily and clearly decouple the code used to implement
* the business logic (as of the plugin implementation) from the code required
* to implement some of the jQuery's best practices when creating new jQuery plugins.
*
* ====== Sample plugin implementation object: ======
*
* // Creates all the business logic of your plugin (aka your plugin implementation object)
* var testPluginCode = {
* _defaults: {}, // you can put your plugin defaults in here.
*
* init: function() {
* // plugin initialization goes here.
* // this method is called just once per instance.
* // you can use this.element to access the HTML element on which the plugin was called at.
* // this.$element is the same as $(this.element).
* // this.options represents the options object passed in during plugin initialization, merged with the _defaults value defined for your plugin.
* // this._name represents the name on which the plugin was registered at the $.fn scope.
* },
*
* doSomething: function(paramA, paramB) {
* // plugin business logic for method "doSomething".
* }
* };
*
* // Creates your plugin, which will be called "myPlugin",
* // using the "testPluginCode" object as the plugin implementation code.
* (function($){
* $.createPlugin('myPlugin', testPluginCode);
* }(jQuery));
*
* // Now, you can use your plugin the same way you'd use any other jQuery plugin:
*
* var myDiv = $('#testDiv'); ...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.