In this article, we are going to see, how to create a jquery plugin.
sometimes you want to make a piece of functionality available throughout your code. for example, you want a single method you can call on a jquery selection that performs a series of operations on the selection. in this case, you may want to write a plugin.
here I'm writing a basic jquery plugin
(function($) {
$.TDATE = (function() {
return new Date();
})();
}(jQuery));
or:
(function($) {
$.TSUM = function(a,b) {
return a + b;
};
}(jQuery));
or:
(function($) {
$.fn.TCOLOR = function() {
this.css('color','red');
return this;
};
}(jQuery));
$('#error').TCOLOR();
0 Comments
if you have any doubts , please let me know