jQuery.fn.tplclick = function( handler ) {
return this.each(function(){
$( this ).click(function( event ){
!this.count && (this.count = 0);
if( ++this.count === 3 ) {
this.count = 0;
handler.call( this, event );
}
})
});
}
$("button").tplclick(function(e) {
console.log(e);
console.log(this);
alert("Triple click");
});