JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/dot-luv/jquery-ui.css">
<button>Click Me</button>
JavaScript
(function($)
{
$.fn.myPlugin = function(options)
{
var _this;
var timer1;
var foo = function(n)
{
if (timer1 != null) return; // in action
timer1 = setInterval(function() { bar(n) }, 500);
};
var bar = function(n)
{
//...
//if ( ... ) clearInterval(timer1);
console.log(n);
};
return this.each(function()
{
_this = $(this);
_this.bind("click", function(){ foo(10); });
});
}
})(jQuery);
$("button").myPlugin();