Created
October 15, 2012 00:16
-
-
Save rodrigo-x/3890247 to your computer and use it in GitHub Desktop.
snippet - teste plugin jquery...
This file contains hidden or 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
;(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