The Code is as follows:
Copy codeThe Code is as follows:
JQuery. event. special. tripleclick = {
Setup: function (data, namespaces ){
Var elem = this, $ elem = jQuery (elem );
$ Elem. bind ('click', jQuery. event. special. tripleclick. handler );
},
Teardown: function (namespaces ){
Var elem = this, $ elem = jQuery (elem );
$ Elem. unbind ('click', jQuery. event. special. tripleclick. handler );
},
Handler: function (event ){
Var elem = this, $ elem = jQuery (elem), clicks = $ elem. data ('clicks') | 0;
Clicks + = 1;
If (clicks = 3 ){
Clicks = 0;
// Set event type to "tripleclick"
Event. type = "tripleclick ";
// Let jQuery handle the triggering of "tripleclick" event handlers
JQuery. event. handle. apply (this, arguments)
}
$ Elem. data ('clicks', clicks );
}
};
Call time:
Copy codeThe Code is as follows:
$ ('# Div'). bind ('tripleclick', function (event ){
// Do something
});