Skip to content

Instantly share code, notes, and snippets.

@rodrigo-x
Created October 15, 2012 00:16
Show Gist options
  • Save rodrigo-x/3890247 to your computer and use it in GitHub Desktop.
Save rodrigo-x/3890247 to your computer and use it in GitHub Desktop.
snippet - teste plugin jquery...
;(function($){
Class = {
init: function(){
this.each(function(){
var $this = $(this);
$this.click(function(){
$this.css('background-color', 'red');
alert('oi')
})
});
return this;
}
}
$.fn.efeito = function(){
var method = arguments[0];
if(Class[method]){
method = Class[method];
arguments = Array.prototype.slice.call(arguments, 1);
}else if(typeof(method) == 'object' || !method){
method = Class.init;
}else {
$.error('Esse método: ' + method + ' não existe!');
return this;
}
return method.apply(this, arguments);
}
})(jQuery);
$(function(){
$('.teste').efeito('init');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment