Skip to content

Instantly share code, notes, and snippets.

@bnoden
Last active May 25, 2016 21:58
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 bnoden/c8469f5d0b4d81ac599c5911c7c6376d to your computer and use it in GitHub Desktop.
Save bnoden/c8469f5d0b4d81ac599c5911c7c6376d to your computer and use it in GitHub Desktop.
jquery quick button maker
$(document).ready(function(){
// Modify as needed to suit project
function quickBtn(txt, tag, cls){
this.txt = txt;
this.tag = '<'+tag+'>';
this.tagClose = '</'+tag+'>';
this.cls = cls;
};
quickBtn.prototype.make = function(element){
element.addClass('btn '+this.cls).html(this.tag+this.txt+this.tagClose);
};
// demonstration:
var quoteBtn = new quickBtn('quote', 'p', 'rQuote'); // Use CSS for class attributes
$('.'+quoteBtn.cls).on('click', function(){
});
$(function init(){
quoteBtn.make(newQuote);
}());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment