Skip to content

Instantly share code, notes, and snippets.

@joe-watkins
Last active June 5, 2016 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joe-watkins/062e82917e028195554658f875d1510b to your computer and use it in GitHub Desktop.
Save joe-watkins/062e82917e028195554658f875d1510b to your computer and use it in GitHub Desktop.
Vanilla JS plugin starter
var someCoolPlugin = function(options){
// defaults
var defaults = {
el: ".anchor-to-button",
killHref: true,
parent: document
}
// loop through defaults
// if the default isn't defined as an option
// use default value for option
for(var i in defaults){
if(typeof options[i] === "undefined") {
options[i] = defaults[i];
}
}
// ... begin code
} // someCoolPlugin
var convertedButtons = new someCoolPlugin({
el: ".dropdown-toggle"
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment