Last active
May 25, 2016 21:58
-
-
Save bnoden/c8469f5d0b4d81ac599c5911c7c6376d to your computer and use it in GitHub Desktop.
jquery quick button maker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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