simple jquery plugin
Couple of method stubs for easy to implement jquery plugins
by peterbenoit
HTML
<div></div>
<div></div>
CSS
div {
width:100px;height:100px;
background:green;
}
JavaScript
// basic
;(function(w,$){
if(!$) return false;
$.fn.extend({
yellowify: function(){
return this.each(function(){
$(this).css("background","yellow");
});
}
});
})(window, jQuery);
$("div:eq(0)").yellowify();
// and, with options
;(function(w,$){
if(!$) return false;
$.fn.extend({
borderify: function(opts){
var defaults = {
width: "1px",
style: "solid",
color: '#000'
};
var opts = $.extend(defaults, opts);
return this.each(function(){
var o = opts;
var obj = $(this);
console.log(o.type);
obj.css({
"border-width": o.width,
"border-color": o.color,
"border-style": o.style
});
});
}
});
})(window, jQuery);
$("div:eq(1)").borderify({width:"2px"});