[Plugin jQuery] estructura basica de un plugin jQuery #js #jquery #plugin
(function ($) {
$.fn.textField = function(cmd) {
var _this = this;
if(arguments.length == 0) { // init
// init code here
_this.val("lalala");
} else {
if(cmd == "algo") {
// hacer ese algo
}
}
};
// defaults
$.fn.textField.defaults = {
foreground: "red",
background: "yellow"
};
}(jQuery));
// Plugin defaults – added as a property on our plugin function.